[testlib] remove support for deprecated module level fixture names

setup_module() and teardown_module() support have been deprecated 4 years ago in commit 06755c704e60.

authorDavid Douard <david.douard@logilab.fr>
changesetdebb3a42631a
branchdefault
phasepublic
hiddenno
parent revision#24ee8e69bec3 [registry] raise a typed exception rather than a bare Exception
child revision#7d33521d00ab delete unused and untested modules (closes #2402)
files modified by this revision
logilab/common/testlib.py
# HG changeset patch
# User David Douard <david.douard@logilab.fr>
# Date 1417101092 -3600
# Thu Nov 27 16:11:32 2014 +0100
# Node ID debb3a42631a069504b09845450799c8b6dc282c
# Parent 24ee8e69bec3ddbd01a8e227d5205d12644465a3
[testlib] remove support for deprecated module level fixture names

setup_module() and teardown_module() support have been deprecated 4
years ago in commit 06755c704e60.

diff --git a/logilab/common/testlib.py b/logilab/common/testlib.py
@@ -328,67 +328,10 @@
1      "Used by the TestSuite to hold previous class when running in debug."
2      _previousTestClass = None
3      _moduleSetUpFailed = False
4      shouldStop = False
5 
6 -from logilab.common.decorators import monkeypatch
7 -@monkeypatch(unittest.TestSuite)
8 -def _handleModuleTearDown(self, result):
9 -    previousModule = self._get_previous_module(result)
10 -    if previousModule is None:
11 -        return
12 -    if result._moduleSetUpFailed:
13 -        return
14 -    try:
15 -        module = sys.modules[previousModule]
16 -    except KeyError:
17 -        return
18 -    # add testlib specific deprecation warning and switch to new api
19 -    if hasattr(module, 'teardown_module'):
20 -        warnings.warn('Please rename teardown_module() to tearDownModule() instead.',
21 -                      DeprecationWarning)
22 -        setattr(module, 'tearDownModule', module.teardown_module)
23 -    # end of monkey-patching
24 -    tearDownModule = getattr(module, 'tearDownModule', None)
25 -    if tearDownModule is not None:
26 -        try:
27 -            tearDownModule()
28 -        except Exception as e:
29 -            if isinstance(result, _DebugResult):
30 -                raise
31 -            errorName = 'tearDownModule (%s)' % previousModule
32 -            self._addClassOrModuleLevelException(result, e, errorName)
33 -
34 -@monkeypatch(unittest.TestSuite)
35 -def _handleModuleFixture(self, test, result):
36 -    previousModule = self._get_previous_module(result)
37 -    currentModule = test.__class__.__module__
38 -    if currentModule == previousModule:
39 -        return
40 -    self._handleModuleTearDown(result)
41 -    result._moduleSetUpFailed = False
42 -    try:
43 -        module = sys.modules[currentModule]
44 -    except KeyError:
45 -        return
46 -    # add testlib specific deprecation warning and switch to new api
47 -    if hasattr(module, 'setup_module'):
48 -        warnings.warn('Please rename setup_module() to setUpModule() instead.',
49 -                      DeprecationWarning)
50 -        setattr(module, 'setUpModule', module.setup_module)
51 -    # end of monkey-patching
52 -    setUpModule = getattr(module, 'setUpModule', None)
53 -    if setUpModule is not None:
54 -        try:
55 -            setUpModule()
56 -        except Exception as e:
57 -            if isinstance(result, _DebugResult):
58 -                raise
59 -            result._moduleSetUpFailed = True
60 -            errorName = 'setUpModule (%s)' % currentModule
61 -            self._addClassOrModuleLevelException(result, e, errorName)
62 -
63  # backward compatibility: TestSuite might be imported from lgc.testlib
64  TestSuite = unittest.TestSuite
65 
66  class keywords(dict):
67      """Keyword args (**kwargs) support for generative tests."""