1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
import re
import os
import tempfile
import unittest2 as unittest
import warnings
import pickle
import sys
import nose.config
from nose.plugins.manager import DefaultPluginManager
from nose.plugins.skip import SkipTest
class TestNoseConfig(unittest.TestCase):
def test_defaults(self):
c = nose.config.Config()
assert c.addPaths == True
# FIXME etc
def test_reset(self):
c = nose.config.Config()
c.include = 'include'
assert c.include == 'include'
c.reset()
assert c.include is None
def test_update(self):
c = nose.config.Config()
c.update({'exclude':'x'})
assert c.exclude == 'x'
def test_multiple_include(self):
c = nose.config.Config()
c.configure(['program', '--include=a', '--include=b'])
self.assertEqual(len(c.include), 2)
a, b = c.include
assert a.match('a')
assert not a.match('b')
assert b.match('b')
assert not b.match('a')
def test_single_include(self):
c = nose.config.Config()
c.configure(['program', '--include=b'])
self.assertEqual(len(c.include), 1)
b = c.include[0]
assert b.match('b')
assert not b.match('a')
def test_plugins(self):
c = nose.config.Config()
assert c.plugins
c.plugins.begin()
def test_testnames(self):
c = nose.config.Config()
c.configure(['program', 'foo', 'bar', 'baz.buz.biz'])
self.assertEqual(c.testNames, ['foo', 'bar', 'baz.buz.biz'])
c = nose.config.Config(testNames=['foo'])
c.configure([])
self.assertEqual(c.testNames, ['foo'])
def test_where(self):
# we don't need to see our own warnings
warnings.filterwarnings(action='ignore',
category=DeprecationWarning,
module='nose.config')
here = os.path.dirname(__file__)
support = os.path.join(here, 'support')
foo = os.path.abspath(os.path.join(support, 'foo'))
c = nose.config.Config()
c.configure(['program', '-w', foo, '-w', 'bar'])
self.assertEqual(c.workingDir, foo)
self.assertEqual(c.testNames, ['bar'])
def test_progname_looks_like_option(self):
# issue #184
c = nose.config.Config()
# the -v here is the program name, not an option
# this matters eg. with python -c "import nose; nose.main()"
c.configure(['-v', 'mytests'])
self.assertEqual(c.verbosity, 1)
def test_pickle_empty(self):
c = nose.config.Config()
cp = pickle.dumps(c)
cc = pickle.loads(cp)
def test_pickle_configured(self):
if 'java' in sys.version.lower():
raise SkipTest("jython has no profiler plugin")
c = nose.config.Config(plugins=DefaultPluginManager())
c.configure(['--with-doctest', '--with-coverage', '--with-profile',
'--with-id', '--attr=A', '--collect', '--all',
'--with-isolation', '-d', '--with-xunit', '--processes=2',
'--pdb'])
cp = pickle.dumps(c)
cc = pickle.loads(cp)
assert cc.plugins._plugins
if __name__ == '__main__':
unittest.main()
|