diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-08-29 12:32:40 +0300 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-08-29 12:32:40 +0300 |
commit | c07e4756def1c264799e682b10a052d8791d30cc (patch) | |
tree | 7936cea8ff6502caca0756e29af5068a0a35ff4e /unit_tests/test_config.py | |
download | python-nose-c07e4756def1c264799e682b10a052d8791d30cc.tar.gz python-nose-c07e4756def1c264799e682b10a052d8791d30cc.tar.bz2 python-nose-c07e4756def1c264799e682b10a052d8791d30cc.zip |
Imported Upstream version 0.11.4upstream/0.11.4
Diffstat (limited to 'unit_tests/test_config.py')
-rw-r--r-- | unit_tests/test_config.py | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/unit_tests/test_config.py b/unit_tests/test_config.py new file mode 100644 index 0000000..8887ddd --- /dev/null +++ b/unit_tests/test_config.py @@ -0,0 +1,106 @@ +import re +import os +import tempfile +import 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() |