Elffuss BraidHub

kikocis/auto-code-rover public

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