diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-10-14 00:55:12 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-10-14 00:55:12 (GMT) |
commit | 7ab986dd84b43742af9b504e0c7acfef8f231ab3 (patch) | |
tree | 73df0e8900a8bd0c09826c6ff09c5314af25b9c9 /Lib/test/test_bytes.py | |
parent | 03dab786b2f504791ac46a9f9b9db82e634efd05 (diff) | |
download | cpython-7ab986dd84b43742af9b504e0c7acfef8f231ab3.zip cpython-7ab986dd84b43742af9b504e0c7acfef8f231ab3.tar.gz cpython-7ab986dd84b43742af9b504e0c7acfef8f231ab3.tar.bz2 |
Fix test_bytes on Windows
On Windows, sprintf("%p", 0xabcdef) formats hexadecimal in uppercase and pad to
16 characters (on 64-bit system) with zeros.
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r-- | Lib/test/test_bytes.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 5fe193e..947d959 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -782,7 +782,7 @@ class BytesTest(BaseBytesTest, unittest.TestCase): # Test PyBytes_FromFormat() def test_from_format(self): - test.support.import_module('ctypes') + ctypes = test.support.import_module('ctypes') _testcapi = test.support.import_module('_testcapi') from ctypes import pythonapi, py_object from ctypes import ( @@ -825,9 +825,12 @@ class BytesTest(BaseBytesTest, unittest.TestCase): b'i=-123') self.assertEqual(PyBytes_FromFormat(b'x=%x', c_int(0xabc)), b'x=abc') - self.assertEqual(PyBytes_FromFormat(b'ptr=%p', - c_char_p(0xabcdef)), - b'ptr=0xabcdef') + ptr = 0xabcdef + expected = [b'ptr=%#x' % ptr] + win_format = 'ptr=0x%0{}X'.format(2 * ctypes.sizeof(c_char_p)) + expected.append((win_format % ptr).encode('ascii')) + self.assertIn(PyBytes_FromFormat(b'ptr=%p', c_char_p(ptr)), + expected) self.assertEqual(PyBytes_FromFormat(b's=%s', c_char_p(b'cstr')), b's=cstr') |