Merge pull request #8 from millerdev/exclude-tests-env

Add support for NOSE_EXCLUDE_TESTS env variable
This commit is contained in:
kurt grandis 2016-09-06 14:06:41 -04:00 committed by GitHub
commit fab9d41262
3 changed files with 25 additions and 5 deletions

View File

@ -74,11 +74,12 @@ To exclude test functions:
Using Environment Variables
---------------------------
``--exclude-dir=`` can be set by the environment variables ``NOSE_EXCLUDE_DIRS``.
Multiple exclude paths may be entered by separating them using a ``;``.
The 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=``.
``--exclude-dir=`` and ``--exclude-test=`` can be set by the environment
variables ``NOSE_EXCLUDE_DIRS`` and ``NOSE_EXCLUDE_TESTS`` respectively.
Multiple exclude paths may be entered by separating them using a ``;``. The
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
========================

View File

@ -25,6 +25,10 @@ class NoseExclude(Plugin):
exclude_dirs = env.get('NOSE_EXCLUDE_DIRS', '')
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(
str("--exclude-dir"), action="append",
dest="exclude_dirs",

View File

@ -144,6 +144,21 @@ class TestNoseExcludeTestNegative(PluginTester, unittest.TestCase):
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):
"""Test nose-exclude multiple tests"""