Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4e59af7

Browse files
committed
#7855: merge with 3.3.
2 parents a8bc7fd + 28faf03 commit 4e59af7

5 files changed

Lines changed: 51 additions & 1 deletion

File tree

Lib/ctypes/test/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def get_tests(package, mask, verbosity, exclude=()):
6262
continue
6363
try:
6464
mod = __import__(modname, globals(), locals(), ['*'])
65-
except ResourceDenied as detail:
65+
except (ResourceDenied, unittest.SkipTest) as detail:
6666
skipped.append(modname)
6767
if verbosity > 1:
6868
print("Skipped %s: %s" % (modname, detail), file=sys.stderr)

Lib/ctypes/test/test_wintypes.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import sys
2+
import unittest
3+
4+
if not sys.platform.startswith('win'):
5+
raise unittest.SkipTest('Windows-only test')
6+
7+
from ctypes import *
8+
from ctypes import wintypes
9+
10+
class WinTypesTest(unittest.TestCase):
11+
def test_variant_bool(self):
12+
# reads 16-bits from memory, anything non-zero is True
13+
for true_value in (1, 32767, 32768, 65535, 65537):
14+
true = POINTER(c_int16)(c_int16(true_value))
15+
value = cast(true, POINTER(wintypes.VARIANT_BOOL))
16+
self.assertEqual(repr(value.contents), 'VARIANT_BOOL(True)')
17+
18+
vb = wintypes.VARIANT_BOOL()
19+
self.assertIs(vb.value, False)
20+
vb.value = True
21+
self.assertIs(vb.value, True)
22+
vb.value = true_value
23+
self.assertIs(vb.value, True)
24+
25+
for false_value in (0, 65536, 262144, 2**33):
26+
false = POINTER(c_int16)(c_int16(false_value))
27+
value = cast(false, POINTER(wintypes.VARIANT_BOOL))
28+
self.assertEqual(repr(value.contents), 'VARIANT_BOOL(False)')
29+
30+
# allow any bool conversion on assignment to value
31+
for set_value in (65536, 262144, 2**33):
32+
vb = wintypes.VARIANT_BOOL()
33+
vb.value = set_value
34+
self.assertIs(vb.value, True)
35+
36+
vb = wintypes.VARIANT_BOOL()
37+
vb.value = [2, 3]
38+
self.assertIs(vb.value, True)
39+
vb.value = []
40+
self.assertIs(vb.value, False)
41+
42+
if __name__ == "__main__":
43+
unittest.main()

Lib/test/test_winreg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,9 @@ def test_disable_reflection(self):
457457
DeleteKeyEx(HKEY_CURRENT_USER, test_reflect_key_name,
458458
KEY_WOW64_32KEY, 0)
459459

460+
def test_exception_numbers(self):
461+
with self.assertRaises(FileNotFoundError) as ctx:
462+
QueryValue(HKEY_CLASSES_ROOT, 'some_value_that_does_not_exist')
460463

461464
def test_main():
462465
support.run_unittest(LocalWinregTests, RemoteWinregTests,

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,7 @@ Nikita Vetoshkin
12871287
Al Vezza
12881288
Jacques A. Vidrine
12891289
John Viega
1290+
Dino Viehland
12901291
Kannan Vijayan
12911292
Kurt Vile
12921293
Norman Vine

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ Library
188188
Tests
189189
-----
190190

191+
- Issue #7855: Add tests for ctypes/winreg for issues found in IronPython.
192+
Initial patch by Dino Viehland.
193+
191194
- Issue #11078: test___all__ now checks for duplicates in __all__.
192195
Initial patch by R. David Murray.
193196

0 commit comments

Comments
 (0)