def test_verbose(self): orig = objc.options.verbose try: with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") objc.setVerbose(False) objc.getVerbose() self.assertEqual(len(w), 2) self.assertEqual(w[0].category, DeprecationWarning) self.assertEqual(w[1].category, DeprecationWarning) with warnings.catch_warnings(record=True): warnings.simplefilter("ignore") self.assertEqual(objc.getVerbose(), orig) objc.setVerbose(False) self.assertEqual(objc.options.verbose, False) self.assertEqual(objc.getVerbose(), False) objc.setVerbose(True) self.assertEqual(objc.options.verbose, True) self.assertEqual(objc.getVerbose(), True) finally: objc.options.verbose = orig
def test_verbose(self): orig = objc.options.verbose try: with filterWarnings("error", DeprecationWarning): self.assertRaises(DeprecationWarning, objc.setVerbose, False) self.assertRaises(DeprecationWarning, objc.getVerbose) with filterWarnings("ignore", DeprecationWarning): self.assertEqual(objc.getVerbose(), orig) objc.setVerbose(False) self.assertEqual(objc.options.verbose, False) self.assertEqual(objc.getVerbose(), False) objc.setVerbose(True) self.assertEqual(objc.options.verbose, True) self.assertEqual(objc.getVerbose(), True) finally: objc.options.verbose = orig
def testSortInvalid(self): # Invalid calls to sortUsingFunction:context: a = NSMutableArray.arrayWithArray_(range(4)) self.assertEquals(a, (0, 1, 2, 3)) t = objc.getVerbose() objc.setVerbose(0) try: self.assertRaises(TypeError, a.sortUsingFunction_context_, dir) self.assertRaises(TypeError, a.sortUsingFunction_context_, dir, 1, 2) self.assertRaises(TypeError, a.sortUsingFunction_context_, cmp, u'a') finally: objc.setVerbose(t)
def testSortInvalid(self): # Invalid calls to sortUsingFunction:context: def cmp(a, b): return -1 a = NSMutableArray.arrayWithArray_(range(4)) self.assertEqual(a, (0, 1, 2, 3)) t = objc.getVerbose() objc.setVerbose(0) try: self.assertRaises(TypeError, a.sortUsingFunction_context_, dir) self.assertRaises(TypeError, a.sortUsingFunction_context_, dir, 1, 2) self.assertRaises(TypeError, a.sortUsingFunction_context_, lambda *args: cmp(*args), b'a'.decode('ascii')) finally: objc.setVerbose(t)
def testSortInvalid(self): # Invalid calls to sortUsingFunction:context: def cmp(a, b): return -1 a = NSMutableArray.arrayWithArray_(range(4)) self.assertEqual(a, (0, 1, 2, 3)) t = objc.getVerbose() objc.setVerbose(0) try: self.assertRaises(TypeError, a.sortUsingFunction_context_, dir) self.assertRaises(TypeError, a.sortUsingFunction_context_, dir, 1, 2) self.assertRaises(TypeError, a.sortUsingFunction_context_, lambda *args: cmp(*args), u'a') finally: objc.setVerbose(t)
def testSortInvalid(self): """ Invalid calls to sortUsingFunction:context: """ a = NSMutableArray.arrayWithArray_(range(4)) self.assertEquals(a, (0, 1, 2, 3)) t = objc.getVerbose() objc.setVerbose(0) try: self.assertRaises(TypeError, a.sortUsingFunction_context_, dir) self.assertRaises(TypeError, a.sortUsingFunction_context_, dir, 1, 2) self.assertRaises(TypeError, a.sortUsingFunction_context_, cmp, u'a') finally: objc.setVerbose(t)