Ejemplo n.º 1
0
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,))
Ejemplo n.º 2
0
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, ))
Ejemplo n.º 3
0
def isTestCase(obj):
    try:
        return ITestCase.implementedBy(obj)
    except TypeError:
        return False
    except AttributeError:
        return False
Ejemplo n.º 4
0
 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))
Ejemplo n.º 5
0
 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))
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
 def test_holderImplementsITestCase(self):
     """
     L{runner.TestHolder} implements L{ITestCase}.
     """
     self.assertIdentical(self.holder, ITestCase(self.holder))
Ejemplo n.º 11
0
 def setUp(self):
     self.original = self.PyUnitTest('test_pass')
     self.test = ITestCase(self.original)
Ejemplo n.º 12
0
 def setUp(self):
     self.original = self.PyUnitTest('test_pass')
     self.test = ITestCase(self.original)