From 94282bd8c1ba269b67164c08e1119db7f2f7226b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= Date: Mon, 30 Sep 2024 19:26:23 +0900 Subject: [PATCH] Respect `PURE_PYTHON` environment variable set to `0` (#158) Setting to 0 should be equivalent to not setting the variable. Refs https://github.com/zopefoundation/meta/issues/283 --- CHANGES.rst | 2 ++ src/AccessControl/tests/testSecurityManager.py | 5 +++-- src/AccessControl/tests/testZopeSecurityPolicy.py | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 467d54c..edacea0 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,8 @@ For changes before version 3.0, see ``HISTORY.rst``. 7.1 (unreleased) ---------------- +- Respect ``PURE_PYTHON`` environment variable set to ``0`` when running tests. + 7.0 (2024-05-30) ---------------- diff --git a/src/AccessControl/tests/testSecurityManager.py b/src/AccessControl/tests/testSecurityManager.py index 5a86d5d..7087330 100644 --- a/src/AccessControl/tests/testSecurityManager.py +++ b/src/AccessControl/tests/testSecurityManager.py @@ -14,9 +14,10 @@ """Tests for the SecurityManager implementations """ -import os import unittest +from ..Implementation import PURE_PYTHON + _THREAD_ID = 123 @@ -251,7 +252,7 @@ def _getTargetClass(self): return SecurityManager -@unittest.skipIf(os.environ.get('PURE_PYTHON'), reason="Test expects C impl.") +@unittest.skipIf(PURE_PYTHON, reason="Test expects C impl.") class C_SecurityManagerTests(SecurityManagerTestBase, ISecurityManagerConformance, unittest.TestCase): diff --git a/src/AccessControl/tests/testZopeSecurityPolicy.py b/src/AccessControl/tests/testZopeSecurityPolicy.py index 9b12a0f..068c49b 100644 --- a/src/AccessControl/tests/testZopeSecurityPolicy.py +++ b/src/AccessControl/tests/testZopeSecurityPolicy.py @@ -12,7 +12,6 @@ ############################################################################## import _thread as thread -import os import sys import unittest from doctest import DocTestSuite @@ -27,6 +26,8 @@ from AccessControl.SecurityManagement import SecurityContext from AccessControl.userfolder import UserFolder +from ..Implementation import PURE_PYTHON + user_roles = ('RoleOfUser',) eo_roles = ('RoleOfExecutableOwner',) @@ -772,7 +773,7 @@ def test_suite(): unittest.defaultTestLoader.loadTestsFromTestCase(Python_ZSPTests)) suite.addTest( unittest.defaultTestLoader.loadTestsFromTestCase(Python_SMTests)) - if not os.environ.get('PURE_PYTHON'): + if not PURE_PYTHON: suite.addTest( unittest.defaultTestLoader.loadTestsFromTestCase(C_ZSPTests)) suite.addTest(