We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5bd4af8 commit 12c8770Copy full SHA for 12c8770
tests/test_pickle_exception.py
@@ -1,3 +1,4 @@
1
+import os
2
from traceback import format_exception
3
4
try:
@@ -345,3 +346,20 @@ def test_oserror_simple():
345
346
assert exc.errno == 13
347
assert exc.strerror == 'Permission denied'
348
assert exc.__traceback__ is not None
349
+
350
351
+def test_real_oserror():
352
+ try:
353
+ os.open('non-existing-file', os.O_RDONLY)
354
+ except Exception as e:
355
+ exc = e
356
+ else:
357
+ pytest.fail('os.open should have raised an OSError')
358
359
+ str_output = str(exc)
360
+ tblib.pickling_support.install(exc)
361
+ exc = pickle.loads(pickle.dumps(exc))
362
363
+ assert isinstance(exc, OSError)
364
+ assert exc.errno == 2
365
+ assert str_output == str(exc)
0 commit comments