From f80e84436fa71fd83fff0b1b5d64935e97cb873d Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Sat, 22 Apr 2023 02:16:22 +0200 Subject: [PATCH] Add another (risky) tests for __setstate__ behaviour --- tests/test_acls.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_acls.py b/tests/test_acls.py index f3b1bb1..5bb4837 100644 --- a/tests/test_acls.py +++ b/tests/test_acls.py @@ -540,6 +540,22 @@ class TestAclExtensions: with pytest.raises(IOError): a.__setstate__(nulled) + @require_copy_ext + def test_acl_copy_ext_failure(self): + a = posix1e.ACL(text=BASIC_ACL_TEXT) + b = posix1e.ACL() + c = posix1e.ACL(acl=a) + assert a == c + assert a != b + state = b.__getstate__() + # See notes in the test_acl_copy_ext_failure() for how tricky this is. + nulled = b'\x00' * len(state) + with pytest.raises(IOError): + a.__setstate__(nulled) + # Assert that 'a' didn't change in the attempt to restore + # invalid state. + assert a == c + @require_copy_ext def test_acl_copy_ext_args(self): a = posix1e.ACL() -- 2.39.2