/
usr
/
lib
/
python2.6
/
site-packages
/
nose
/
plugins
/
/usr/lib/python2.6/site-packages/nose/plugins
mkdir
upload
Name
Size
Mode
Actions
attrib.py
7810
0644
edit
dl
rm
attrib.pyc
7428
0644
edit
dl
rm
attrib.pyo
7428
0644
edit
dl
rm
base.py
31384
0644
edit
dl
rm
base.pyc
36810
0644
edit
dl
rm
base.pyo
36810
0644
edit
dl
rm
builtin.py
792
0644
edit
dl
rm
builtin.pyc
1369
0644
edit
dl
rm
builtin.pyo
1369
0644
edit
dl
rm
capture.py
2780
0644
edit
dl
rm
capture.pyc
4565
0644
edit
dl
rm
capture.pyo
4565
0644
edit
dl
rm
cover.py
6416
0644
edit
dl
rm
cover.pyc
6213
0644
edit
dl
rm
cover.pyo
6213
0644
edit
dl
rm
debug.py
1679
0644
edit
dl
rm
debug.pyc
2481
0644
edit
dl
rm
debug.pyo
2481
0644
edit
dl
rm
deprecated.py
1639
0644
edit
dl
rm
deprecated.pyc
2385
0644
edit
dl
rm
deprecated.pyo
2385
0644
edit
dl
rm
doctests.py
9147
0644
edit
dl
rm
doctests.pyc
9891
0644
edit
dl
rm
doctests.pyo
9891
0644
edit
dl
rm
errorclass.py
6438
0644
edit
dl
rm
errorclass.pyc
8037
0644
edit
dl
rm
errorclass.pyo
8037
0644
edit
dl
rm
failuredetail.py
1564
0644
edit
dl
rm
failuredetail.pyc
2334
0644
edit
dl
rm
failuredetail.pyo
2334
0644
edit
dl
rm
isolate.py
3674
0644
edit
dl
rm
isolate.pyc
4729
0644
edit
dl
rm
isolate.pyo
4729
0644
edit
dl
rm
manager.py
14330
0644
edit
dl
rm
manager.pyc
18370
0644
edit
dl
rm
manager.pyo
18370
0644
edit
dl
rm
plugintest.py
7994
0644
edit
dl
rm
plugintest.pyc
9644
0644
edit
dl
rm
plugintest.pyo
9644
0644
edit
dl
rm
prof.py
4744
0644
edit
dl
rm
prof.pyc
4933
0644
edit
dl
rm
prof.pyo
4933
0644
edit
dl
rm
skip.py
1572
0644
edit
dl
rm
skip.pyc
2289
0644
edit
dl
rm
skip.pyo
2289
0644
edit
dl
rm
testid.py
4871
0644
edit
dl
rm
testid.pyc
5479
0644
edit
dl
rm
testid.pyo
5479
0644
edit
dl
rm
__init__.py
8169
0644
edit
dl
rm
__init__.pyc
8412
0644
edit
dl
rm
__init__.pyo
8412
0644
edit
dl
rm
Edit:
/usr/lib/python2.6/site-packages/nose/plugins/isolate.py
(3674B)
"""Use the isolation plugin with --with-isolation or the NOSE_WITH_ISOLATION environment variable to clean sys.modules after each test module is loaded and executed. The isolation module is in effect similar to wrapping the following functions around the import and execution of each test module:: def setup(module): module._mods = sys.modules.copy() def teardown(module): to_del = [ m for m in sys.modules.keys() if m not in module._mods ] for mod in to_del: del sys.modules[mod] sys.modules.update(module._mods) Isolation works only during lazy loading. In normal use, this is only during discovery of modules within a directory, where the process of importing, loading tests and running tests from each module is encapsulated in a single loadTestsFromName call. This plugin implements loadTestsFromNames to force the same lazy-loading there, which allows isolation to work in directed mode as well as discovery, at the cost of some efficiency: lazy-loading names forces full context setup and teardown to run for each name, defeating the grouping that is normally used to ensure that context setup and teardown are run the fewest possible times for a given set of names. PLEASE NOTE that this plugin should not be used in conjunction with other plugins that assume that modules once imported will stay imported; for instance, it may cause very odd results when used with the coverage plugin. """ import logging import sys from nose.plugins import Plugin log = logging.getLogger('nose.plugins.isolation') class IsolationPlugin(Plugin): """ Activate the isolation plugin to isolate changes to external modules to a single test module or package. The isolation plugin resets the contents of sys.modules after each test module or package runs to its state before the test. PLEASE NOTE that this plugin should not be used with the coverage plugin in any other case where module reloading may produce undesirable side-effects. """ score = 10 # I want to be last name = 'isolation' def configure(self, options, conf): Plugin.configure(self, options, conf) self._mod_stack = [] def beforeContext(self): """Copy sys.modules onto my mod stack """ mods = sys.modules.copy() self._mod_stack.append(mods) def afterContext(self): """Pop my mod stack and restore sys.modules to the state it was in when mod stack was pushed. """ mods = self._mod_stack.pop() to_del = [ m for m in sys.modules.keys() if m not in mods ] if to_del: log.debug('removing sys modules entries: %s', to_del) for mod in to_del: del sys.modules[mod] sys.modules.update(mods) def loadTestsFromNames(self, names, module=None): """Create a lazy suite that calls beforeContext and afterContext around each name. The side-effect of this is that full context fixtures will be set up and torn down around each test named. """ # Fast path for when we don't care if not names or len(names) == 1: return loader = self.loader plugins = self.conf.plugins def lazy(): for name in names: plugins.beforeContext() yield loader.loadTestsFromName(name, module=module) plugins.afterContext() return (loader.suiteClass(lazy), []) def prepareTestLoader(self, loader): """Get handle on test loader so we can use it in loadTestsFromNames. """ self.loader = loader
Save
cmd:
run