| 1 | str() on the pytest.raises context variable doesn't behave same as normal exception catch |
| 2 | Pytest 4.6.2, macOS 10.14.5 |
| 3 | |
| 4 | ```Python |
| 5 | try: |
| 6 | raise LookupError( |
| 7 | f"A\n" |
| 8 | f"B\n" |
| 9 | f"C" |
| 10 | ) |
| 11 | except LookupError as e: |
| 12 | print(str(e)) |
| 13 | ``` |
| 14 | prints |
| 15 | |
| 16 | > A |
| 17 | > B |
| 18 | > C |
| 19 | |
| 20 | But |
| 21 | |
| 22 | ```Python |
| 23 | with pytest.raises(LookupError) as e: |
| 24 | raise LookupError( |
| 25 | f"A\n" |
| 26 | f"B\n" |
| 27 | f"C" |
| 28 | ) |
| 29 | |
| 30 | print(str(e)) |
| 31 | ``` |
| 32 | |
| 33 | prints |
| 34 | |
| 35 | > <console>:3: LookupError: A |
| 36 | |
| 37 | In order to get the full error message, one must do `str(e.value)`, which is documented, but this is a different interaction. Any chance the behavior could be changed to eliminate this gotcha? |
| 38 | |
| 39 | ----- |
| 40 | |
| 41 | Pip list gives |
| 42 | |
| 43 | ``` |
| 44 | Package Version Location |
| 45 | ------------------ -------- ------------------------------------------------------ |
| 46 | apipkg 1.5 |
| 47 | asn1crypto 0.24.0 |
| 48 | atomicwrites 1.3.0 |
| 49 | attrs 19.1.0 |
| 50 | aws-xray-sdk 0.95 |
| 51 | boto 2.49.0 |
| 52 | boto3 1.9.51 |
| 53 | botocore 1.12.144 |
| 54 | certifi 2019.3.9 |
| 55 | cffi 1.12.3 |
| 56 | chardet 3.0.4 |
| 57 | Click 7.0 |
| 58 | codacy-coverage 1.3.11 |
| 59 | colorama 0.4.1 |
| 60 | coverage 4.5.3 |
| 61 | cryptography 2.6.1 |
| 62 | decorator 4.4.0 |
| 63 | docker 3.7.2 |
| 64 | docker-pycreds 0.4.0 |
| 65 | docutils 0.14 |
| 66 | ecdsa 0.13.2 |
| 67 | execnet 1.6.0 |
| 68 | future 0.17.1 |
| 69 | idna 2.8 |
| 70 | importlib-metadata 0.17 |
| 71 | ipaddress 1.0.22 |
| 72 | Jinja2 2.10.1 |
| 73 | jmespath 0.9.4 |
| 74 | jsondiff 1.1.1 |
| 75 | jsonpickle 1.1 |
| 76 | jsonschema 2.6.0 |
| 77 | MarkupSafe 1.1.1 |
| 78 | mock 3.0.4 |
| 79 | more-itertools 7.0.0 |
| 80 | moto 1.3.7 |
| 81 | neobolt 1.7.10 |
| 82 | neotime 1.7.4 |
| 83 | networkx 2.1 |
| 84 | numpy 1.15.0 |
| 85 | packaging 19.0 |
| 86 | pandas 0.24.2 |
| 87 | pip 19.1.1 |
| 88 | pluggy 0.12.0 |
| 89 | prompt-toolkit 2.0.9 |
| 90 | py 1.8.0 |
| 91 | py2neo 4.2.0 |
| 92 | pyaml 19.4.1 |
| 93 | pycodestyle 2.5.0 |
| 94 | pycparser 2.19 |
| 95 | pycryptodome 3.8.1 |
| 96 | Pygments 2.3.1 |
| 97 | pyOpenSSL 19.0.0 |
| 98 | pyparsing 2.4.0 |
| 99 | pytest 4.6.2 |
| 100 | pytest-cache 1.0 |
| 101 | pytest-codestyle 1.4.0 |
| 102 | pytest-cov 2.6.1 |
| 103 | pytest-forked 1.0.2 |
| 104 | python-dateutil 2.7.3 |
| 105 | python-jose 2.0.2 |
| 106 | pytz 2018.5 |
| 107 | PyYAML 5.1 |
| 108 | requests 2.21.0 |
| 109 | requests-mock 1.5.2 |
| 110 | responses 0.10.6 |
| 111 | s3transfer 0.1.13 |
| 112 | setuptools 41.0.1 |
| 113 | six 1.11.0 |
| 114 | sqlite3worker 1.1.7 |
| 115 | tabulate 0.8.3 |
| 116 | urllib3 1.24.3 |
| 117 | wcwidth 0.1.7 |
| 118 | websocket-client 0.56.0 |
| 119 | Werkzeug 0.15.2 |
| 120 | wheel 0.33.1 |
| 121 | wrapt 1.11.1 |
| 122 | xlrd 1.1.0 |
| 123 | xmltodict 0.12.0 |
| 124 | zipp 0.5.1 |
| 125 | ``` |