Skip to content

Commit b541a12

Browse files
Test failures
1 parent b26b3cb commit b541a12

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

pyobjc-framework-Cocoa/PyObjCTest/test_nsstring.py

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,37 +60,40 @@ def testTypesAndClasses(self):
6060

6161
@onlyPython2
6262
def testStrConversion(self):
63-
curEnabledFlag = objc.getStrBridgeEnabled()
64-
objc.setStrBridgeEnabled(True)
65-
try:
66-
v = NSString.stringWithString_("hello2")
67-
self.assertIsInstance(v, objc.pyobjc_unicode)
68-
self.assertEqual(v, b"hello2".decode('ascii'))
63+
with warnings.catch_warnings():
64+
warnings.filterwarnings("ignore")
6965

66+
curEnabledFlag = objc.getStrBridgeEnabled()
67+
objc.setStrBridgeEnabled(True)
68+
try:
69+
v = NSString.stringWithString_("hello2")
70+
self.assertIsInstance(v, objc.pyobjc_unicode)
71+
self.assertEqual(v, b"hello2".decode('ascii'))
7072

71-
self.assertRaises(UnicodeError, unicode, "\xff")
72-
# XXX: string bridge now uses the default NSString encoding
73-
# self.assertRaises(UnicodeError, NSString.stringWithString_, '\xff')
7473

75-
objc.setStrBridgeEnabled(False)
74+
self.assertRaises(UnicodeError, unicode, "\xff")
75+
# XXX: string bridge now uses the default NSString encoding
76+
# self.assertRaises(UnicodeError, NSString.stringWithString_, '\xff')
7677

77-
warnings.filterwarnings('error', category=objc.PyObjCStrBridgeWarning)
78-
try:
79-
#v = NSString.stringWithString_("hello")
78+
objc.setStrBridgeEnabled(False)
8079

81-
# we need to make sure that the str is unique
82-
# because an already bridged one might have crossed
83-
# and would be cached
84-
newString = type('test_str', (str,), {})('hello2')
85-
self.assertRaises(objc.PyObjCStrBridgeWarning,
86-
NSString.stringWithString_, newString)
80+
warnings.filterwarnings('error', category=objc.PyObjCStrBridgeWarning)
81+
try:
82+
#v = NSString.stringWithString_("hello")
8783

88-
finally:
89-
del warnings.filters[0]
84+
# we need to make sure that the str is unique
85+
# because an already bridged one might have crossed
86+
# and would be cached
87+
newString = type('test_str', (str,), {})('hello2')
88+
self.assertRaises(objc.PyObjCStrBridgeWarning,
89+
NSString.stringWithString_, newString)
9090

91+
finally:
92+
del warnings.filters[0]
9193

92-
finally:
93-
objc.setStrBridgeEnabled(curEnabledFlag)
94+
95+
finally:
96+
objc.setStrBridgeEnabled(curEnabledFlag)
9497

9598
def testNSStringMethodAccess(self):
9699
self.assertIsInstance(self.nsUniString, objc.pyobjc_unicode)

pyobjc-framework-Quartz/PyObjCTest/test_cgdirectdisplay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def testFunctions(self):
218218
self.assertEqual(err, 0)
219219

220220
v = CGDisplayIsCaptured(CGMainDisplayID())
221-
self.failIf(v)
221+
self.assertFalse(v)
222222

223223
err = CGDisplayCaptureWithOptions(CGMainDisplayID(), 0)
224224
self.assertEqual(err, 0)

0 commit comments

Comments
 (0)