From e83b8282ceadb8818c6b79b995589b34818e6a69 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Sun, 27 Dec 2009 17:10:08 +0100 Subject: [PATCH] Unittest fixes for python 3 --- Makefile | 3 ++- tests/test_acls.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index e8fde0c..20029f4 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,9 @@ doc: posix1e.so posix1e test: - for ver in 2.4 2.5 2.6; do \ + for ver in 2.4 2.5 2.6 3.0 3.1; do \ if type python$$ver >/dev/null; then \ + echo Testing with python$$ver; \ python$$ver ./setup.py test; \ fi; \ done diff --git a/tests/test_acls.py b/tests/test_acls.py index 68cd432..b7b899d 100644 --- a/tests/test_acls.py +++ b/tests/test_acls.py @@ -32,6 +32,12 @@ TEST_DIR = os.environ.get("TESTDIR", ".") BASIC_ACL_TEXT = "u::rw,g::r,o::-" +# This is to workaround python 2/3 differences at syntactic level +# (which can't be worked around via if's) +M0500 = 320 # octal 0500 +M0644 = 420 # octal 0644 +M0755 = 493 # octal 755 + def _skip_test(fn): """Wrapper to skip a test""" new_fn = lambda x: None @@ -124,7 +130,7 @@ class AclExtensions(aclTest, unittest.TestCase): @has_ext(HAS_ACL_FROM_MODE) def testFromMode(self): """Test loading ACLs from an octal mode""" - acl1 = posix1e.ACL(mode=0644) + acl1 = posix1e.ACL(mode=M0644) self.failUnless(acl1.valid(), "ACL created via octal mode shoule be valid") @@ -157,13 +163,13 @@ class AclExtensions(aclTest, unittest.TestCase): def testEquivMode(self): """Test the equiv_mode function""" if HAS_ACL_FROM_MODE: - for mode in 0644, 0755: + for mode in M0644, M0755: acl = posix1e.ACL(mode=mode) self.failUnlessEqual(acl.equiv_mode(), mode) acl = posix1e.ACL(text="u::rw,g::r,o::r") - self.failUnlessEqual(acl.equiv_mode(), 0644) + self.failUnlessEqual(acl.equiv_mode(), M0644) acl = posix1e.ACL(text="u::rx,g::-,o::-") - self.failUnlessEqual(acl.equiv_mode(), 0500) + self.failUnlessEqual(acl.equiv_mode(), M0500) class WriteTests(aclTest, unittest.TestCase): -- 2.39.5