Skip to content

Commit

Permalink
Fix some test failures after a run with python 3.6 - 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldoussoren committed Jan 22, 2022
1 parent a204225 commit a0be1e4
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 14 deletions.
3 changes: 2 additions & 1 deletion pyobjc-core/Lib/PyObjCTools/TestSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ def assertIsCFType(self, tp, message=None):
# self.fail(message or "%r is not a CFTypeRef subclass"%(tp,))

def assertIsEnumType(self, tp):
if _sys.version_info < (3, 8):
tmp = _typing.NewType("tmp", int)
if isinstance(tmp, type(lambda: 1)):
# typing.NewType is not a type in Python 3.7 or earlier
if not isinstance(tp, type(lambda: 1)):
self.fail(f"{tp!r} is not a typing.NewType")
Expand Down
9 changes: 6 additions & 3 deletions pyobjc-core/PyObjCTest/test_assocations.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@ def testInvalidCalls(self):
o = NSObject.alloc().init()
key1 = "key1"
with self.assertRaisesRegex(
TypeError, r"function missing required argument 'value' \(pos 3\)"
TypeError,
r"(function missing required argument 'value' \(pos 3\))|(Required argument 'value' \(pos 3\) not found)",
):
objc.setAssociatedObject(o, key1)

with self.assertRaisesRegex(
TypeError, r"function missing required argument 'key' \(pos 2\)"
TypeError,
r"(function missing required argument 'key' \(pos 2\))|(Required argument 'key' \(pos 2\) not found)",
):
objc.getAssociatedObject(o)

with self.assertRaisesRegex(
TypeError, r"function missing required argument 'object' \(pos 1\)"
TypeError,
r"(function missing required argument 'object' \(pos 1\))|(Required argument 'object' \(pos 1\) not found)",
):
objc.removeAssociatedObjects()

Expand Down
6 changes: 4 additions & 2 deletions pyobjc-core/PyObjCTest/test_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,14 @@ def replacement3_(self, arg):
class TestRescanClass(TestCase):
def test_invalid_usage(self):
with self.assertRaisesRegex(
TypeError, r"function missing required argument 'name' \(pos 1\)"
TypeError,
r"(function missing required argument 'name' \(pos 1\))|(Required argument 'name' \(pos 1\) not found)",
):
objc._rescanClass()

with self.assertRaisesRegex(
TypeError, r"function missing required argument 'name' \(pos 1\)"
TypeError,
r"(function missing required argument 'name' \(pos 1\))|(Required argument 'name' \(pos 1\) not found)",
):
objc._rescanClass(naam="NSObject")

Expand Down
3 changes: 2 additions & 1 deletion pyobjc-core/PyObjCTest/test_ivar.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ def __pyobjc_object__(self):
setter(obj, "rectValue", 42)

with self.assertRaisesRegex(
TypeError, r"function missing required argument 'name' \(pos 2\)"
TypeError,
r"(function missing required argument 'name' \(pos 2\))|(Required argument 'name' \(pos 2\) not found)",
):
setter(obj)

Expand Down
4 changes: 2 additions & 2 deletions pyobjc-core/PyObjCTest/test_methodedits.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ class TestFromObjCSuperToObjCClass(TestCase):
def test_invalid_adding(self):
with self.assertRaisesRegex(
TypeError,
r"classAddMethods\(\) missing required argument 'methodsArray' \(pos 2\)",
r"(classAddMethods\(\) missing required argument 'methodsArray' \(pos 2\))|(Required argument 'methodsArray' \(pos 2\) not found)", # noqa: B950
):
objc.classAddMethods(NSObject)

with self.assertRaisesRegex(
TypeError,
r"classAddMethods\(\) missing required argument 'targetClass' \(pos 1\)",
r"(classAddMethods\(\) missing required argument 'targetClass' \(pos 1\))|(Required argument 'targetClass' \(pos 1\) not found)", # noqa: B950
):
objc.classAddMethods(aClass=NSObject, methods=[])

Expand Down
3 changes: 2 additions & 1 deletion pyobjc-core/PyObjCTest/test_number_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ def testClasses(self):

def test_repythonify_invalid(self):
with self.assertRaisesRegex(
TypeError, r"function missing required argument 'obj' \(pos 1\)"
TypeError,
r"(function missing required argument 'obj' \(pos 1\))|(Required argument 'obj' \(pos 1\) not found)",
):
objc.repythonify()

Expand Down
3 changes: 2 additions & 1 deletion pyobjc-core/PyObjCTest/test_pointer_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def test_voidp_using_ctypes(self):

def test_pyobjc_id_invalid(self):
with self.assertRaisesRegex(
TypeError, r"function missing required argument 'obj' \(pos 1\)"
TypeError,
r"(function missing required argument 'obj' \(pos 1\))|(Required argument 'obj' \(pos 1\) not found)",
):
objc.pyobjc_id()

Expand Down
3 changes: 2 additions & 1 deletion pyobjc-core/PyObjCTest/test_python_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
class TestPythonMethod(TestCase):
def test_creation(self):
with self.assertRaisesRegex(
TypeError, r"function missing required argument 'callable' \(pos 1\)"
TypeError,
r"(function missing required argument 'callable' \(pos 1\))|(Required argument 'callable' \(pos 1\) not found)",
):
objc.python_method()
with self.assertRaisesRegex(
Expand Down
3 changes: 2 additions & 1 deletion pyobjc-core/PyObjCTest/test_version_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def test_macos_available(self):
)

with self.assertRaisesRegex(
TypeError, r"function missing required argument 'major' \(pos 1\)"
TypeError,
r"(function missing required argument 'major' \(pos 1\))|(Required argument 'major' \(pos 1\) not found)",
):
objc.macos_available()

Expand Down
3 changes: 2 additions & 1 deletion pyobjc-core/PyObjCTest/test_weakref.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def test_weakref_call_interface(self):
r(x=1)

with self.assertRaisesRegex(
TypeError, r"function missing required argument 'object' \(pos 1\)"
TypeError,
r"(function missing required argument 'object' \(pos 1\))|(Required argument 'object' \(pos 1\) not found)",
):
objc.WeakRef(value=o)

Expand Down

0 comments on commit a0be1e4

Please sign in to comment.