Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PURE_PYTHON instead of AC_PURE_PYTHON #120

Merged
merged 11 commits into from
Feb 16, 2022
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
# with `test`, and `docs` must use a subset.
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version:
- 2.7
Expand Down Expand Up @@ -171,6 +172,7 @@ jobs:
needs: build-package
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version:
- 2.7
Expand Down Expand Up @@ -231,7 +233,7 @@ jobs:
python -m coverage run -p -m zope.testrunner --test-path=src --auto-color --auto-progress
- name: Run tests without C extensions
run: |
AC_PURE_PYTHON=1 python -m coverage run -p -m zope.testrunner --test-path=src --auto-color --auto-progress
PURE_PYTHON=1 AC_PURE_PYTHON=1 python -m coverage run -p -m zope.testrunner --test-path=src --auto-color --auto-progress
icemac marked this conversation as resolved.
Show resolved Hide resolved
- name: Report Coverage
run: |
coverage combine
Expand Down
1 change: 1 addition & 0 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ parts = interpreter test coverage
[versions]
AccessControl =
RestrictedPython =
Acquisition = 4.10

[interpreter]
recipe = zc.recipe.egg
Expand Down
9 changes: 2 additions & 7 deletions src/AccessControl/ImplPython.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@
from ExtensionClass import Base
from zope.interface import implementer

# This is used when a permission maps explicitly to no permission. We
# try and get this from cAccessControl first to make sure that if both
# security implementations exist, we can switch between them later.
try:
from AccessControl.cAccessControl import _what_not_even_god_should_do
except ImportError:
_what_not_even_god_should_do = []
# We define our own `_what_not_even_god_should_do` to allow using PURE_PYTHON=1
_what_not_even_god_should_do = []

from AccessControl.interfaces import ISecurityManager
from AccessControl.interfaces import ISecurityPolicy
Expand Down
2 changes: 2 additions & 0 deletions src/AccessControl/Implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@

"""
from __future__ import absolute_import

import os


# We cannot use `PURE_PYTHON` as this would be propagated to `ExtensionClass`
# and `Acquisition`. Due to restrictions of python implementation concerning
# proxies it is not possible to run all with pure python and we influence only
Expand Down
2 changes: 2 additions & 0 deletions src/AccessControl/tests/testSecurityManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""Tests for the SecurityManager implementations
"""

import os
import unittest


Expand Down Expand Up @@ -250,6 +251,7 @@ def _getTargetClass(self):
return SecurityManager


@unittest.skipIf(os.environ.get('PURE_PYTHON'), reason="Test expects C impl.")
class C_SecurityManagerTests(SecurityManagerTestBase,
ISecurityManagerConformance,
unittest.TestCase):
Expand Down
2 changes: 2 additions & 0 deletions src/AccessControl/tests/testZopeGuards.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ class TestGuardedHasattr(GuardTestCase):
def setUp(self):
self.__sm = SecurityManager()
self.__old = self.setSecurityManager(self.__sm)
gc.disable()

def tearDown(self):
self.setSecurityManager(self.__old)
gc.enable()

def test_miss(self):
from AccessControl.ZopeGuards import guarded_hasattr
Expand Down
6 changes: 4 additions & 2 deletions src/AccessControl/tests/testZopeSecurityPolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#
##############################################################################

import os
import sys
import unittest
from doctest import DocTestSuite
Expand Down Expand Up @@ -775,9 +776,10 @@ def loop():
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(Python_ZSPTests))
suite.addTest(unittest.makeSuite(C_ZSPTests))
suite.addTest(unittest.makeSuite(Python_SMTests))
suite.addTest(unittest.makeSuite(C_SMTests))
if not os.environ.get('PURE_PYTHON'):
suite.addTest(unittest.makeSuite(C_ZSPTests))
suite.addTest(unittest.makeSuite(C_SMTests))
suite.addTest(DocTestSuite())
suite.addTest(unittest.makeSuite(GetRolesWithMultiThreadTest))
return suite
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ deps =
setuptools < 52
zc.buildout
skip_install = true
setenv =
PURE_PYTHON=1
AC_PURE_PYTHON=1

[testenv:coverage]
basepython = python3
Expand Down