Merge pull request #8 from millerdev/exclude-tests-env
Add support for NOSE_EXCLUDE_TESTS env variable
This commit is contained in:
commit
fab9d41262
11
README.rst
11
README.rst
|
@ -74,11 +74,12 @@ To exclude test functions:
|
||||||
Using Environment Variables
|
Using Environment Variables
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
``--exclude-dir=`` can be set by the environment variables ``NOSE_EXCLUDE_DIRS``.
|
``--exclude-dir=`` and ``--exclude-test=`` can be set by the environment
|
||||||
Multiple exclude paths may be entered by separating them using a ``;``.
|
variables ``NOSE_EXCLUDE_DIRS`` and ``NOSE_EXCLUDE_TESTS`` respectively.
|
||||||
The environment variable ``NOSE_EXCLUDE_DIRS_FILE`` when set to the path of a
|
Multiple exclude paths may be entered by separating them using a ``;``. The
|
||||||
file-based exclusion list functions as though it were passed in with ``--exclude-dir-file=``.
|
environment variable ``NOSE_EXCLUDE_DIRS_FILE`` when set to the path of a
|
||||||
|
file-based exclusion list functions as though it were passed in with
|
||||||
|
``--exclude-dir-file=``.
|
||||||
|
|
||||||
Nose Configuration Files
|
Nose Configuration Files
|
||||||
========================
|
========================
|
||||||
|
|
|
@ -25,6 +25,10 @@ class NoseExclude(Plugin):
|
||||||
exclude_dirs = env.get('NOSE_EXCLUDE_DIRS', '')
|
exclude_dirs = env.get('NOSE_EXCLUDE_DIRS', '')
|
||||||
env_dirs.extend(exclude_dirs.split(';'))
|
env_dirs.extend(exclude_dirs.split(';'))
|
||||||
|
|
||||||
|
if 'NOSE_EXCLUDE_TESTS' in env:
|
||||||
|
exclude_tests = env.get('NOSE_EXCLUDE_TESTS', '')
|
||||||
|
env_tests.extend(exclude_tests.split(';'))
|
||||||
|
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
str("--exclude-dir"), action="append",
|
str("--exclude-dir"), action="append",
|
||||||
dest="exclude_dirs",
|
dest="exclude_dirs",
|
||||||
|
|
15
tests.py
15
tests.py
|
@ -144,6 +144,21 @@ class TestNoseExcludeTestNegative(PluginTester, unittest.TestCase):
|
||||||
assert 'Ran 3 tests' in self.output
|
assert 'Ran 3 tests' in self.output
|
||||||
|
|
||||||
|
|
||||||
|
class TestNoseExcludeTestsEnvVariables(PluginTester, unittest.TestCase):
|
||||||
|
"""Test nose-exclude's use of environment variables"""
|
||||||
|
|
||||||
|
activate = "-v"
|
||||||
|
plugins = [NoseExclude()]
|
||||||
|
suitepath = os.path.join(os.getcwd(), 'test_dirs/unittest')
|
||||||
|
env = {'NOSE_EXCLUDE_TESTS':
|
||||||
|
'test_dirs.unittest.tests.UnitTests.test_a;'
|
||||||
|
'test_dirs.unittest.tests.test_c'
|
||||||
|
}
|
||||||
|
|
||||||
|
def test_test_excluded(self):
|
||||||
|
assert 'Ran 1 test' in self.output
|
||||||
|
|
||||||
|
|
||||||
class TestNoseExcludeMultipleTest(PluginTester, unittest.TestCase):
|
class TestNoseExcludeMultipleTest(PluginTester, unittest.TestCase):
|
||||||
"""Test nose-exclude multiple tests"""
|
"""Test nose-exclude multiple tests"""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue