Ticket #3231: remove-visitors.patch

File remove-visitors.patch, 12.0 KB (added by Vladimir Perić, 7 years ago)
  • twisted/trial/runner.py

    diff --git twisted/trial/runner.py twisted/trial/runner.py
    index 24f5d13..e8a8a64 100644
    Maintainer: Jonathan Lange 
    99"""
    1010
    1111__all__ = [
    12     'suiteVisit', 'TestSuite',
     12    'TestSuite',
    1313
    1414    'DestructiveTestSuite', 'DocTestCase', 'DryRunVisitor',
    1515    'ErrorHolder', 'LoggedSuite', 'PyUnitTestCase',
    from twisted.trial.itrial import ITestCase 
    3232from twisted.trial.reporter import UncleanWarningsReporterWrapper
    3333
    3434# These are imported so that they remain in the public API for t.trial.runner
    35 from twisted.trial.unittest import suiteVisit, TestSuite
     35from twisted.trial.unittest import TestSuite
    3636
    3737from zope.interface import implements
    3838
  • twisted/trial/test/moduletest.py

    diff --git twisted/trial/test/moduletest.py twisted/trial/test/moduletest.py
    index c5e1d70..2a8cc69 100644
     
    1 # -*- test-case-name: twisted.trial.test.test_test_visitor -*-
     1# -*- test-case-name: twisted.trial.test.test_log -*-
    22
    33# fodder for test_script, which parses files for emacs local variable
    44# declarations.  This one is supposed to have:
    5 #    test-case-name: twisted.trial.test.test_test_visitor.
     5#    test-case-name: twisted.trial.test.test_log.
    66# in the first line
    77# The class declaration is irrelevant
    88
  • twisted/trial/test/scripttest.py

    diff --git twisted/trial/test/scripttest.py twisted/trial/test/scripttest.py
    index 267c189..3a2bf47 100644
     
    11#!/usr/bin/env python
    2 # -*- test-case-name: twisted.trial.test.test_test_visitor,twisted.trial.test.test_class -*-
     2# -*- test-case-name: twisted.trial.test.test_log,twisted.trial.test.test_class -*-
    33
    44# Copyright (c) Twisted Matrix Laboratories.
    55# See LICENSE for details.
    66
    77# fodder for test_script, which parses files for emacs local variable
    88# declarations.  This one is supposed to have:
    9 #    test-case-name: twisted.trial.test.test_test_visitor
     9#    test-case-name: twisted.trial.test.test_log
    1010# in the second line
    1111# The class declaration is irrelevant
    1212
  • twisted/trial/test/test_loader.py

    diff --git twisted/trial/test/test_loader.py twisted/trial/test/test_loader.py
    index f08588e..151f3a9 100644
    class LoaderTest(packages.SysPathManglingTest): 
    471471        """
    472472        Check that loadByNames ignores duplicate names
    473473        """
    474         module = 'twisted.trial.test.test_test_visitor'
     474        module = 'twisted.trial.test.test_log'
    475475        suite1 = self.loader.loadByNames([module, module], True)
    476476        suite2 = self.loader.loadByName(module, True)
    477477        self.assertSuitesEqual(suite1, suite2)
  • twisted/trial/test/test_pyunitcompat.py

    diff --git twisted/trial/test/test_pyunitcompat.py twisted/trial/test/test_pyunitcompat.py
    index 72e7f11..ee0f9c8 100644
    class TestPyUnitTestCase(TestCase): 
    3232        self.test = ITestCase(self.original)
    3333
    3434
    35     def test_visit(self):
    36         """
    37         Trial assumes that test cases implement visit().
    38         """
    39         log = []
    40         def visitor(test):
    41             log.append(test)
    42         self.test.visit(visitor)
    43         self.assertEqual(log, [self.test])
    44     test_visit.suppress = [
    45         util.suppress(category=DeprecationWarning,
    46                       message="Test visitors deprecated in Twisted 8.0")]
    47 
    48 
    4935    def test_callable(self):
    5036        """
    5137        Tests must be callable in order to be used with Python's unittest.py.
  • twisted/trial/test/test_script.py

    diff --git twisted/trial/test/test_script.py twisted/trial/test/test_script.py
    index a8d489d..83d3398 100644
    class TestModuleTest(unittest.TestCase): 
    146146        """
    147147        self.config.opt_testmodule(sibpath('moduletest.py'))
    148148        self.assertSuitesEqual(trial._getSuite(self.config),
    149                                ['twisted.trial.test.test_test_visitor'])
     149                               ['twisted.trial.test.test_log'])
    150150
    151151    def test_testmoduleTwice(self):
    152152        """
    class TestModuleTest(unittest.TestCase): 
    156156        self.config.opt_testmodule(sibpath('moduletest.py'))
    157157        self.config.opt_testmodule(sibpath('moduletest.py'))
    158158        self.assertSuitesEqual(trial._getSuite(self.config),
    159                                ['twisted.trial.test.test_test_visitor'])
     159                               ['twisted.trial.test.test_log'])
    160160
    161161    def test_testmoduleOnSourceAndTarget(self):
    162162        """
    class TestModuleTest(unittest.TestCase): 
    165165        added once.
    166166        """
    167167        self.config.opt_testmodule(sibpath('moduletest.py'))
    168         self.config.opt_testmodule(sibpath('test_test_visitor.py'))
     168        self.config.opt_testmodule(sibpath('test_log.py'))
    169169        self.assertSuitesEqual(trial._getSuite(self.config),
    170                                ['twisted.trial.test.test_test_visitor'])
     170                               ['twisted.trial.test.test_log'])
    171171
    172172    def test_testmoduleOnSelfModule(self):
    173173        """
    class TestModuleTest(unittest.TestCase): 
    185185        """
    186186        self.config.opt_testmodule(sibpath('scripttest.py'))
    187187        self.assertSuitesEqual(trial._getSuite(self.config),
    188                                ['twisted.trial.test.test_test_visitor',
     188                               ['twisted.trial.test.test_log',
    189189                                'twisted.trial.test.test_class'])
    190190
    191191    def test_testmoduleOnNonexistentFile(self):
    class TestModuleTest(unittest.TestCase): 
    274274    def test_variablesFromFile(self):
    275275        localVars = trial.loadLocalVariables(sibpath('moduletest.py'))
    276276        self.assertEqual({'test-case-name':
    277                               'twisted.trial.test.test_test_visitor'},
     277                              'twisted.trial.test.test_log'},
    278278                             localVars)
    279279
    280280    def test_noVariablesInFile(self):
    class TestModuleTest(unittest.TestCase): 
    284284    def test_variablesFromScript(self):
    285285        localVars = trial.loadLocalVariables(sibpath('scripttest.py'))
    286286        self.assertEqual(
    287             {'test-case-name': ('twisted.trial.test.test_test_visitor,'
     287            {'test-case-name': ('twisted.trial.test.test_log,'
    288288                                'twisted.trial.test.test_class')},
    289289            localVars)
    290290
    291291    def test_getTestModules(self):
    292292        modules = trial.getTestModules(sibpath('moduletest.py'))
    293         self.assertEqual(modules, ['twisted.trial.test.test_test_visitor'])
     293        self.assertEqual(modules, ['twisted.trial.test.test_log'])
    294294
    295295    def test_getTestModules_noVars(self):
    296296        modules = trial.getTestModules(sibpath('novars.py'))
    class TestModuleTest(unittest.TestCase): 
    299299    def test_getTestModules_multiple(self):
    300300        modules = trial.getTestModules(sibpath('scripttest.py'))
    301301        self.assertEqual(set(modules),
    302                              set(['twisted.trial.test.test_test_visitor',
     302                             set(['twisted.trial.test.test_log',
    303303                                  'twisted.trial.test.test_class']))
    304304
    305305    def test_looksLikeTestModule(self):
  • deleted file twisted/trial/test/test_test_visitor.py

    diff --git twisted/trial/test/test_test_visitor.py twisted/trial/test/test_test_visitor.py
    deleted file mode 100644
    index b5c3484..0000000
    + -  
    1 from twisted.trial import unittest
    2 from twisted.trial.runner import TestSuite, suiteVisit
    3 
    4 pyunit = __import__('unittest')
    5 
    6 
    7 
    8 class MockVisitor(object):
    9     def __init__(self):
    10         self.calls = []
    11 
    12 
    13     def __call__(self, testCase):
    14         self.calls.append(testCase)
    15 
    16 
    17 
    18 class TestTestVisitor(unittest.TestCase):
    19     def setUp(self):
    20         self.visitor = MockVisitor()
    21 
    22 
    23     def test_visitCase(self):
    24         """
    25         Test that C{visit} works for a single test case.
    26         """
    27         testCase = TestTestVisitor('test_visitCase')
    28         testCase.visit(self.visitor)
    29         self.assertEqual(self.visitor.calls, [testCase])
    30 
    31 
    32     def test_visitSuite(self):
    33         """
    34         Test that C{visit} hits all tests in a suite.
    35         """
    36         tests = [TestTestVisitor('test_visitCase'),
    37                  TestTestVisitor('test_visitSuite')]
    38         testSuite = TestSuite(tests)
    39         testSuite.visit(self.visitor)
    40         self.assertEqual(self.visitor.calls, tests)
    41 
    42 
    43     def test_visitEmptySuite(self):
    44         """
    45         Test that C{visit} on an empty suite hits nothing.
    46         """
    47         TestSuite().visit(self.visitor)
    48         self.assertEqual(self.visitor.calls, [])
    49 
    50 
    51     def test_visitNestedSuite(self):
    52         """
    53         Test that C{visit} recurses through suites.
    54         """
    55         tests = [TestTestVisitor('test_visitCase'),
    56                  TestTestVisitor('test_visitSuite')]
    57         testSuite = TestSuite([TestSuite([test]) for test in tests])
    58         testSuite.visit(self.visitor)
    59         self.assertEqual(self.visitor.calls, tests)
    60 
    61 
    62     def test_visitPyunitSuite(self):
    63         """
    64         Test that C{suiteVisit} visits stdlib unittest suites
    65         """
    66         test = TestTestVisitor('test_visitPyunitSuite')
    67         suite = pyunit.TestSuite([test])
    68         suiteVisit(suite, self.visitor)
    69         self.assertEqual(self.visitor.calls, [test])
    70 
    71 
    72     def test_visitPyunitCase(self):
    73         """
    74         Test that a stdlib test case in a suite gets visited.
    75         """
    76         class PyunitCase(pyunit.TestCase):
    77             def test_foo(self):
    78                 pass
    79         test = PyunitCase('test_foo')
    80         TestSuite([test]).visit(self.visitor)
    81         self.assertEqual(
    82             [call.id() for call in self.visitor.calls], [test.id()])
  • twisted/trial/unittest.py

    diff --git twisted/trial/unittest.py twisted/trial/unittest.py
    index c6522fe..79e723d 100644
    class TestCase(_Assertions): 
    12011201        return util.acquireAttribute(self._parents, 'suppress', [])
    12021202
    12031203
    1204     def visit(self, visitor):
    1205         """
    1206         Visit this test case. Call C{visitor} with C{self} as a parameter.
    1207 
    1208         Deprecated in Twisted 8.0.
    1209 
    1210         @param visitor: A callable which expects a single parameter: a test
    1211         case.
    1212 
    1213         @return: None
    1214         """
    1215         warnings.warn("Test visitors deprecated in Twisted 8.0",
    1216                       category=DeprecationWarning)
    1217         visitor(self)
    1218 
    1219 
    12201204    def mktemp(self):
    12211205        """Returns a unique name that may be used as either a temporary
    12221206        directory or filename.
    class PyUnitResultAdapter(object): 
    13631347
    13641348
    13651349
    1366 def suiteVisit(suite, visitor):
    1367     """
    1368     Visit each test in C{suite} with C{visitor}.
    1369 
    1370     Deprecated in Twisted 8.0.
    1371 
    1372     @param visitor: A callable which takes a single argument, the L{TestCase}
    1373     instance to visit.
    1374     @return: None
    1375     """
    1376     warnings.warn("Test visitors deprecated in Twisted 8.0",
    1377                   category=DeprecationWarning)
    1378     for case in suite._tests:
    1379         visit = getattr(case, 'visit', None)
    1380         if visit is not None:
    1381             visit(visitor)
    1382         elif isinstance(case, pyunit.TestCase):
    1383             case = itrial.ITestCase(case)
    1384             case.visit(visitor)
    1385         elif isinstance(case, pyunit.TestSuite):
    1386             suiteVisit(case, visitor)
    1387         else:
    1388             case.visit(visitor)
    1389 
    1390 
    1391 
    13921350class TestSuite(pyunit.TestSuite):
    13931351    """
    1394     Extend the standard library's C{TestSuite} with support for the visitor
    1395     pattern and a consistently overrideable C{run} method.
     1352    Extend the standard library's C{TestSuite} with a consistently overrideable
     1353    C{run} method.
    13961354    """
    13971355
    1398     visit = suiteVisit
    1399 
    14001356    def __call__(self, result):
    14011357        return self.run(result)
    14021358
    class _PyUnitTestCaseAdapter(TestDecorator): 
    14961452    """
    14971453
    14981454
    1499     def visit(self, visitor):
    1500         """
    1501         Deprecated in Twisted 8.0.
    1502         """
    1503         warnings.warn("Test visitors deprecated in Twisted 8.0",
    1504                       category=DeprecationWarning)
    1505         visitor(self)
    1506 
    1507 
    15081455
    15091456class _BrokenIDTestCaseAdapter(_PyUnitTestCaseAdapter):
    15101457    """