class TestPyUnitTestCase(TestCase): class PyUnitTest(pyunit.TestCase): def test_pass(self): pass def setUp(self): self.original = self.PyUnitTest('test_pass') self.test = ITestCase(self.original) def test_visit(self): """ Trial assumes that test cases implement visit(). """ log = [] def visitor(test): log.append(test) self.test.visit(visitor) self.assertEqual(log, [self.test]) test_visit.suppress = [ util.suppress(category=DeprecationWarning, message="Test visitors deprecated in Twisted 8.0")] def test_callable(self): """ Tests must be callable in order to be used with Python's unittest.py. """ self.assertTrue(callable(self.test), "%r is not callable." % (self.test,))
class TestPyUnitTestCase(TestCase): class PyUnitTest(pyunit.TestCase): def test_pass(self): pass def setUp(self): self.original = self.PyUnitTest('test_pass') self.test = ITestCase(self.original) def test_visit(self): """ Trial assumes that test cases implement visit(). """ log = [] def visitor(test): log.append(test) self.test.visit(visitor) self.assertEqual(log, [self.test]) test_visit.suppress = [ util.suppress(category=DeprecationWarning, message="Test visitors deprecated in Twisted 8.0") ] def test_callable(self): """ Tests must be callable in order to be used with Python's unittest.py. """ self.assertTrue(callable(self.test), "%r is not callable." % (self.test, ))
def isTestCase(obj): try: return ITestCase.implementedBy(obj) except TypeError: return False except AttributeError: return False
def __init__(self, testModule): warnings.warn("DocTestSuite is deprecated in Twisted 8.0.", category=DeprecationWarning, stacklevel=2) TestSuite.__init__(self) suite = doctest.DocTestSuite(testModule) for test in suite._tests: #yay encapsulation self.addTest(ITestCase(test))
def test_holderImplementsITestCase(self): """ L{runner.TestHolder} implements L{ITestCase}. """ self.assertIdentical(self.holder, ITestCase(self.holder)) self.assertTrue( verifyObject(ITestCase, self.holder), "%r claims to provide %r but does not do so correctly." % (self.holder, ITestCase))
def isTestCase(obj): try: return ITestCase.implementedBy(obj) except TypeError: return False except AttributeError: # Working around a bug in zope.interface 3.1.0; this isn't the user's # fault, so we won't emit a warning. # See http://www.zope.org/Collectors/Zope3-dev/470. return False
def isTestCase(obj): """ Returns C{True} if C{obj} is a class that contains test cases, C{False} otherwise. Used to find all the tests in a module. """ try: return ITestCase.implementedBy(obj) except TypeError: return False except AttributeError: # Working around a bug in zope.interface 3.1.0; this isn't the user's # fault, so we won't emit a warning. # See http://www.zope.org/Collectors/Zope3-dev/470. return False
def test_holderImplementsITestCase(self): """ L{runner.TestHolder} implements L{ITestCase}. """ self.assertIdentical(self.holder, ITestCase(self.holder))
def setUp(self): self.original = self.PyUnitTest('test_pass') self.test = ITestCase(self.original)