Skip to content

Commit 77aa8fa

Browse files
committed
Add a test for exception raising when pickling.
1 parent 74de841 commit 77aa8fa

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/test_lazy_object_proxy.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,18 @@ def test_pickling(lazy_object_proxy, obj, pickler, level):
17491749
assert obj == result
17501750

17511751

1752+
@pytest.mark.parametrize("level", range(pickle.HIGHEST_PROTOCOL + 1))
1753+
def test_pickling_exception(lazy_object_proxy, pickler, level):
1754+
class BadStuff(Exception):
1755+
pass
1756+
1757+
def trouble_maker():
1758+
raise BadStuff("foo")
1759+
1760+
proxy = lazy_object_proxy.Proxy(trouble_maker)
1761+
pytest.raises(BadStuff, pickler.dumps, proxy, protocol=level)
1762+
1763+
17521764
@pytest.mark.skipif(platform.python_implementation() != 'CPython',
17531765
reason="Interpreter doesn't have reference counting")
17541766
def test_garbage_collection(lazy_object_proxy):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy