summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Balcerzak <lukaszbalcerzak@gmail.com>2013-05-09 17:16:46 +0200
committerLukasz Balcerzak <lukaszbalcerzak@gmail.com>2013-05-09 17:16:46 +0200
commiteccfc3b643ceb019dd324c28050e54b9b9db22a5 (patch)
tree33dade7000772914c040258d0f6709ee025bd72b
parentf59cda79adc4dfa87c40a3f7939e21533caab186 (diff)
downloadnose-eccfc3b643ceb019dd324c28050e54b9b9db22a5.tar.gz
Added NOSE_IGNORE_CONFIG_FILES as env variable option
-rw-r--r--doc/usage.rst5
-rw-r--r--nose/core.py9
-rw-r--r--unit_tests/test_core.py33
3 files changed, 45 insertions, 2 deletions
diff --git a/doc/usage.rst b/doc/usage.rst
index 11e682b..381b6b6 100644
--- a/doc/usage.rst
+++ b/doc/usage.rst
@@ -13,6 +13,11 @@ standard .ini-style config files. Put your nosetests configuration in a
[nosetests]
verbosity=3
with-doctest=1
+
+There is also possiblity to disable configuration files loading (might be
+useful when runnig i.e. tox and you don't want want your global nose config
+file to be used by tox). In order to ignore those configuration files simply
+set an environment variable ``NOSE_IGNORE_CONFIG_FILES``.
There are several other ways to use the nose test runner besides the
`nosetests` script. You may use nose in a test script::
diff --git a/nose/core.py b/nose/core.py
index e57a88f..4d23e38 100644
--- a/nose/core.py
+++ b/nose/core.py
@@ -117,11 +117,18 @@ class TestProgram(unittest.TestProgram):
argv=argv, testRunner=testRunner, testLoader=testLoader,
**extra_args)
+ def getAllConfigFiles(self, env=None):
+ env = env or {}
+ if env.get('NOSE_IGNORE_CONFIG_FILES', False):
+ return []
+ else:
+ return all_config_files()
+
def makeConfig(self, env, plugins=None):
"""Load a Config, pre-filled with user config files if any are
found.
"""
- cfg_files = all_config_files()
+ cfg_files = self.getAllConfigFiles(env)
if plugins:
manager = PluginManager(plugins=plugins)
else:
diff --git a/unit_tests/test_core.py b/unit_tests/test_core.py
index d84c085..94b9436 100644
--- a/unit_tests/test_core.py
+++ b/unit_tests/test_core.py
@@ -4,7 +4,7 @@ import unittest
from cStringIO import StringIO
from optparse import OptionParser
import nose.core
-from nose.config import Config
+from nose.config import Config, all_config_files
from nose.tools import set_trace
from mock import Bucket, MockOptParser
@@ -64,5 +64,36 @@ class TestUsage(unittest.TestCase):
else:
del nose.__loader__
+
+class DummyTestProgram(nose.core.TestProgram):
+ def __init__(self, *args, **kwargs):
+ pass
+
+
+class TestProgramConfigs(unittest.TestCase):
+
+ def setUp(self):
+ self.program = DummyTestProgram()
+
+ def test_getAllConfigFiles(self):
+ self.assertEqual(self.program.getAllConfigFiles(), all_config_files())
+
+ def test_getAllConfigFiles_ignore_configs(self):
+ env = {'NOSE_IGNORE_CONFIG_FILES': 'yes'}
+ self.assertEqual(self.program.getAllConfigFiles(env), [])
+
+ def test_makeConfig(self):
+ calls = []
+ class TestProgramMock(DummyTestProgram):
+ def getAllConfigFiles(self, env):
+ calls.append(env)
+ return []
+
+ program = TestProgramMock()
+ env = {'foo': 'bar'}
+ program.makeConfig(env)
+ self.assertEqual(calls, [env])
+
+
if __name__ == '__main__':
unittest.main()