1. Ronald Oussoren
  2. pyobjc


Ronald Oussoren  committed 7e0ca2c

Use assertStartswith(value, test) instead of assertTrue(value.startswith(test))

  • Participants
  • Parent commits b2d1dc2
  • Branches core-cleanup

Comments (0)

Files changed (3)

File pyobjc-core/Lib/PyObjCTools/TestSupport.py

View file
  • Ignore whitespace
+    if not hasattr(_unittest.TestCase, 'assertStartswith'):
+        def assertStartswith(self, value, test, message = None): # pragma: no cover
+            if not value.startswith(test):
+                self.fail(message or "%r does not start with %r"%(value, test))
     if not hasattr(_unittest.TestCase, 'assertIs'): # pragma: no cover
         def assertIs(self, value, test, message = None):

File pyobjc-core/PyObjCTest/test_bridgesupport.py

View file
  • Ignore whitespace
             self.assertIsInstance(typestr, bytes)
             self.assertIsInstance(doc, (str, type(None)))
             self.assertEqual(len(objc.splitSignature(typestr)), 1)
-            self.assertTrue(typestr.startswith(objc._C_PTR))
+            self.assertStartswith(typestr, objc._C_PTR)
             return '<pointer %r>'%(name,)
         def createStructType(name, typestr, fieldnames, doc=None, pack=-1):

File pyobjc-core/PyObjCTest/test_subclass.py

View file
  • Ignore whitespace
             def foo(self):
-        self.assertTrue(repr(SelectorRepr.foo).startswith('<unbound selector foo of SelectorRepr at'))
+        self.assertStartswith(repr(SelectorRepr.foo), '<unbound selector foo of SelectorRepr at')
 class TestCopying (TestCase):