[Python-checkins] cpython (merge 3.3 -> default): #7855: merge with 3.3.

ezio.melotti python-checkins at python.org
Sat May 4 16:48:08 CEST 2013


http://hg.python.org/cpython/rev/df655ebf74d7
changeset:   83603:df655ebf74d7
parent:      83601:ed0c30b4c082
parent:      83602:5f82b68c1f28
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Sat May 04 17:47:54 2013 +0300
summary:
  #7855: merge with 3.3.

files:
  Lib/ctypes/test/__init__.py      |   2 +-
  Lib/ctypes/test/test_wintypes.py |  43 ++++++++++++++++++++
  Lib/test/test_winreg.py          |   3 +
  Misc/ACKS                        |   1 +
  Misc/NEWS                        |   3 +
  5 files changed, 51 insertions(+), 1 deletions(-)


diff --git a/Lib/ctypes/test/__init__.py b/Lib/ctypes/test/__init__.py
--- a/Lib/ctypes/test/__init__.py
+++ b/Lib/ctypes/test/__init__.py
@@ -62,7 +62,7 @@
             continue
         try:
             mod = __import__(modname, globals(), locals(), ['*'])
-        except ResourceDenied as detail:
+        except (ResourceDenied, unittest.SkipTest) as detail:
             skipped.append(modname)
             if verbosity > 1:
                 print("Skipped %s: %s" % (modname, detail), file=sys.stderr)
diff --git a/Lib/ctypes/test/test_wintypes.py b/Lib/ctypes/test/test_wintypes.py
new file mode 100644
--- /dev/null
+++ b/Lib/ctypes/test/test_wintypes.py
@@ -0,0 +1,43 @@
+import sys
+import unittest
+
+if not sys.platform.startswith('win'):
+    raise unittest.SkipTest('Windows-only test')
+
+from ctypes import *
+from ctypes import wintypes
+
+class WinTypesTest(unittest.TestCase):
+    def test_variant_bool(self):
+        # reads 16-bits from memory, anything non-zero is True
+        for true_value in (1, 32767, 32768, 65535, 65537):
+            true = POINTER(c_int16)(c_int16(true_value))
+            value = cast(true, POINTER(wintypes.VARIANT_BOOL))
+            self.assertEqual(repr(value.contents), 'VARIANT_BOOL(True)')
+
+            vb = wintypes.VARIANT_BOOL()
+            self.assertIs(vb.value, False)
+            vb.value = True
+            self.assertIs(vb.value, True)
+            vb.value = true_value
+            self.assertIs(vb.value, True)
+
+        for false_value in (0, 65536, 262144, 2**33):
+            false = POINTER(c_int16)(c_int16(false_value))
+            value = cast(false, POINTER(wintypes.VARIANT_BOOL))
+            self.assertEqual(repr(value.contents), 'VARIANT_BOOL(False)')
+
+        # allow any bool conversion on assignment to value
+        for set_value in (65536, 262144, 2**33):
+            vb = wintypes.VARIANT_BOOL()
+            vb.value = set_value
+            self.assertIs(vb.value, True)
+
+        vb = wintypes.VARIANT_BOOL()
+        vb.value = [2, 3]
+        self.assertIs(vb.value, True)
+        vb.value = []
+        self.assertIs(vb.value, False)
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py
--- a/Lib/test/test_winreg.py
+++ b/Lib/test/test_winreg.py
@@ -457,6 +457,9 @@
             DeleteKeyEx(HKEY_CURRENT_USER, test_reflect_key_name,
                         KEY_WOW64_32KEY, 0)
 
+    def test_exception_numbers(self):
+        with self.assertRaises(FileNotFoundError) as ctx:
+            QueryValue(HKEY_CLASSES_ROOT, 'some_value_that_does_not_exist')
 
 def test_main():
     support.run_unittest(LocalWinregTests, RemoteWinregTests,
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1287,6 +1287,7 @@
 Al Vezza
 Jacques A. Vidrine
 John Viega
+Dino Viehland
 Kannan Vijayan
 Kurt Vile
 Norman Vine
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -188,6 +188,9 @@
 Tests
 -----
 
+- Issue #7855: Add tests for ctypes/winreg for issues found in IronPython.
+  Initial patch by Dino Viehland.
+
 - Issue #11078: test___all__ now checks for duplicates in __all__.
   Initial patch by R. David Murray.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list