comparison MoinMoin/conftest.py @ 4028:5c78ac77c98f

tests: minor cleanups, remove unused code, fix (c)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 24 Aug 2008 16:01:27 +0200
parents 0d6724b87856
children 3d5c4ebe8f34
comparison
equal deleted inserted replaced
4027:0d6724b87856 4028:5c78ac77c98f
11 instance, can refer to self.request. It is injected into all test case 11 instance, can refer to self.request. It is injected into all test case
12 classes by the framework. 12 classes by the framework.
13 13
14 Tests that require a certain configuration, like section_numbers = 1, must 14 Tests that require a certain configuration, like section_numbers = 1, must
15 use a TestConfig to create the required configuration before the test. 15 use a TestConfig to create the required configuration before the test.
16 Deleting the TestConfig instance will restore the previous configuration.
17 16
18 @copyright: 2005 Nir Soffer, 2007 Alexander Schremmer 17 @copyright: 2005 MoinMoin:NirSoffer,
18 2007 MoinMoin:AlexanderSchremmer,
19 2008 MoinMoin:ThomasWaldmann
19 @license: GNU GPL, see COPYING for details. 20 @license: GNU GPL, see COPYING for details.
20 """ 21 """
21 22
22 import atexit 23 import atexit
23 from sys import modules
24 import sys 24 import sys
25 25
26 import py 26 import py
27 27
28
29 rootdir = py.magic.autopath().dirpath() 28 rootdir = py.magic.autopath().dirpath()
30 moindir = rootdir.join("..") 29 moindir = rootdir.join("..")
31
32 sys.path.insert(0, str(moindir)) 30 sys.path.insert(0, str(moindir))
33 from MoinMoin._tests import maketestwiki, compat, wikiconfig
34 modules["unittest"] = compat # evil hack
35
36 31
37 from MoinMoin.support.python_compatibility import set 32 from MoinMoin.support.python_compatibility import set
33 from MoinMoin._tests import maketestwiki, compat, wikiconfig
34 sys.modules["unittest"] = compat # evil hack
38 35
39 coverage_modules = set() 36 coverage_modules = set()
40
41 37
42 try: 38 try:
43 """ 39 """
44 This code adds support for coverage.py (see 40 This code adds support for coverage.py (see
45 http://nedbatchelder.com/code/modules/coverage.html). 41 http://nedbatchelder.com/code/modules/coverage.html).
49 45
50 import coverage 46 import coverage
51 47
52 def report_coverage(): 48 def report_coverage():
53 coverage.stop() 49 coverage.stop()
54 module_list = [modules[mod] for mod in coverage_modules] 50 module_list = [sys.modules[mod] for mod in coverage_modules]
55 module_list.sort() 51 module_list.sort()
56 coverage.report(module_list) 52 coverage.report(module_list)
57 53
58 def callback(option, opt_str, value, parser): 54 def callback(option, opt_str, value, parser):
59 atexit.register(report_coverage) 55 atexit.register(report_coverage)