summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarius Gedminas <marius@gedmin.as>2013-02-19 09:11:10 +0200
committerMarius Gedminas <marius@gedmin.as>2013-02-19 09:11:10 +0200
commite1d5f7cf375ccdfb8f6207c2bf813ca64c1d7bda (patch)
tree1b61f644d957de39fbf4589ba984392ee74d58ca /src
parent18a6987860cdb622fca9c98fca22692c90fc45f8 (diff)
downloadzope-security-e1d5f7cf375ccdfb8f6207c2bf813ca64c1d7bda.tar.gz
Try to make the tests pass on Windows
Diffstat (limited to 'src')
-rw-r--r--src/zope/security/tests/test_proxy.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/zope/security/tests/test_proxy.py b/src/zope/security/tests/test_proxy.py
index dbf4a1d..e54894d 100644
--- a/src/zope/security/tests/test_proxy.py
+++ b/src/zope/security/tests/test_proxy.py
@@ -14,6 +14,7 @@
"""Security proxy tests
"""
import unittest
+import sys
from zope.security._compat import PYTHON2
@@ -35,6 +36,15 @@ def _skip_if_Py2(testfunc):
return dummy
return testfunc
+def _fmt_address(obj):
+ # Try to replicate PyString_FromString("%p", obj), which actually uses
+ # the platform sprintf(buf, "%p", obj), which we cannot access from Python
+ # directly (and ctypes seems like overkill).
+ if sys.platform == 'win32':
+ return '0x%08x' % id(obj)
+ else:
+ return '0x%0x' % id(obj)
+
class ProxyCTests(unittest.TestCase):
@@ -157,9 +167,10 @@ class ProxyCTests(unittest.TestCase):
target = object()
checker = DummyChecker(ForbiddenAttribute)
proxy = self._makeOne(target, checker)
+ address = _fmt_address(target)
self.assertEqual(str(proxy),
'<security proxied %s.object '
- 'instance at 0x%0x>' % (_BUILTINS, id(target)))
+ 'instance at %s>' % (_BUILTINS, address))
def test___repr___checker_allows_str(self):
target = object()
@@ -173,9 +184,10 @@ class ProxyCTests(unittest.TestCase):
target = object()
checker = DummyChecker(ForbiddenAttribute)
proxy = self._makeOne(target, checker)
+ address = _fmt_address(target)
self.assertEqual(repr(proxy),
'<security proxied %s.object '
- 'instance at 0x%0x>' % (_BUILTINS, id(target)))
+ 'instance at %s>' % (_BUILTINS, address))
@_skip_if_not_Py2
def test___cmp___w_self(self):