From e604e691b5580a0d4ec87bf9b5b44b3d6f5c72ca Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Sun, 6 Dec 2020 14:56:45 +0100 Subject: [PATCH] Test 'filedef' arguments for all supported types Support for unicode/bytes/path objects for filedef was introduced way back in 707c0d4a, but was not tested across all of these. Let's test all of these. Found while investigating #16. --- tests/test_acls.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/test_acls.py b/tests/test_acls.py index 2272d05..2527dc3 100644 --- a/tests/test_acls.py +++ b/tests/test_acls.py @@ -220,6 +220,19 @@ FD_D = [ "file io stream", ] +DIR_D = [ + "directory", + "directory (bytes)", + "directory (path object)", +] + +DIR_P = [ + get_dir, + as_bytes(get_dir), + pytest.param(as_fspath(get_dir), + marks=[NOT_BEFORE_36, NOT_PYPY]), +] + ALL_P = FILE_P + FD_P ALL_D = FILE_D + FD_D @@ -233,6 +246,11 @@ def fd_subject(testdir, request): with request.param(testdir) as value: yield value +@pytest.fixture(params=DIR_P, ids=DIR_D) +def dir_subject(testdir, request): + with request.param(testdir) as value: + yield value + @pytest.fixture(params=ALL_P, ids=ALL_D) def subject(testdir, request): with request.param(testdir) as value: @@ -246,10 +264,9 @@ class TestLoad: acl = posix1e.ACL(file=file_subject) assert acl.valid() - def test_from_dir(self, testdir): + def test_from_dir(self, dir_subject): """Test loading ACLs from a directory""" - with get_dir(testdir) as dname: - acl2 = posix1e.ACL(filedef=dname) + acl2 = posix1e.ACL(filedef=dir_subject) # default ACLs might or might not be valid; missing ones are # not valid, so we don't test acl2 for validity -- 2.39.5