예제 #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,))
예제 #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, ))
예제 #3
0
def isTestCase(obj):
    try:
        return ITestCase.implementedBy(obj)
    except TypeError:
        return False
    except AttributeError:
        return False
예제 #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))
예제 #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))
예제 #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
예제 #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
예제 #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
예제 #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
예제 #10
0
 def test_holderImplementsITestCase(self):
     """
     L{runner.TestHolder} implements L{ITestCase}.
     """
     self.assertIdentical(self.holder, ITestCase(self.holder))
예제 #11
0
 def setUp(self):
     self.original = self.PyUnitTest('test_pass')
     self.test = ITestCase(self.original)
예제 #12
0
 def setUp(self):
     self.original = self.PyUnitTest('test_pass')
     self.test = ITestCase(self.original)