本文整理汇总了Python中nose2.tests._common.support_file函数的典型用法代码示例。如果您正苦于以下问题:Python support_file函数的具体用法?Python support_file怎么用?Python support_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了support_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_name_from_path
def test_name_from_path(self):
test_module = support_file('scenario/tests_in_package/pkg1/test/test_things.py')
test_package_path = support_file('scenario/tests_in_package')
self.assertEqual(
util.name_from_path(test_module),
('pkg1.test.test_things', test_package_path)
)
开发者ID:abetkin,项目名称:nose2,代码行数:7,代码来源:test_util.py
示例2: test_session_config_cacheing
def test_session_config_cacheing(self):
"""Test cacheing of config sections works"""
# Create new session (generic one likely already cached
# depending on test order)
cache_sess = session.Session()
cache_sess.loadConfigFiles(support_file('cfg', 'a.cfg'))
# First access to given section, should read from config file
firstaccess = cache_sess.get('a')
assert firstaccess.as_int("a") == 1
# Hack cached Config object internals to make the stored value
# something different
cache_sess.configCache["a"]._mvd["a"] = "0"
newitems = []
for item in cache_sess.configCache["a"]._items:
if item != ("a", "1"):
newitems.append(item)
else:
newitems.append(("a", "0"))
cache_sess.configCache["a"]._items = newitems
# Second access to given section, confirm returns cached value
# rather than parsing config file again
secondaccess = cache_sess.get("a")
assert secondaccess.as_int("a") == 0
开发者ID:hugovk,项目名称:nose2,代码行数:27,代码来源:test_session.py
示例3: test_module_name_with_start_dir
def test_module_name_with_start_dir(self):
proc = self.runIn(
'.', '-v', '-s', support_file('scenario/tests_in_package'),
'pkg1.test.test_things')
self.assertTestRunOutputMatches(proc, stderr='Ran 25 tests')
self.assertEqual(proc.poll(), 1)
开发者ID:atdt,项目名称:nose2,代码行数:7,代码来源:test_loading.py
示例4: test_dispatch_tests_receive_events
def test_dispatch_tests_receive_events(self):
ssn = {
'config': self.session.config,
'verbosity': 1,
'startDir': support_file('scenario/tests_in_package'),
'topLevelDir': support_file('scenario/tests_in_package'),
'logLevel': 100,
'pluginClasses': [discovery.DiscoveryLoader,
testcases.TestCaseLoader,
buffer.OutputBufferPlugin]
}
conn = Conn(['pkg1.test.test_things.SomeTests.test_ok',
'pkg1.test.test_things.SomeTests.test_failed'])
procserver(ssn, conn)
# check conn calls
expect = [('pkg1.test.test_things.SomeTests.test_ok',
[('startTest', {}),
('setTestOutcome', {'outcome': 'passed'}),
('testOutcome', {'outcome': 'passed'}),
('stopTest', {})]
),
('pkg1.test.test_things.SomeTests.test_failed',
[('startTest', {}),
('setTestOutcome', {
'outcome': 'failed',
'expected': False,
'metadata': {'stdout': 'Hello stdout\n'}}),
('testOutcome', {
'outcome': 'failed',
'expected': False,
'metadata': {'stdout': 'Hello stdout\n'}}),
('stopTest', {})]
),
]
for val in conn.sent:
if val is None:
break
test, events = val
exp_test, exp_events = expect.pop(0)
self.assertEqual(test, exp_test)
for method, event in events:
exp_meth, exp_attr = exp_events.pop(0)
self.assertEqual(method, exp_meth)
for attr, val in exp_attr.items():
self.assertEqual(getattr(event, attr), val)
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:47,代码来源:test_mp_plugin.py
示例5: test_start_directory_inside_package
def test_start_directory_inside_package(self):
proc = self.runIn(
'scenario/tests_in_package/pkg1/test',
'-v',
'-t',
support_file('scenario/tests_in_package'))
self.assertTestRunOutputMatches(proc, stderr='Ran 25 tests')
self.assertEqual(proc.poll(), 1)
开发者ID:abetkin,项目名称:nose2,代码行数:8,代码来源:test_loading.py
示例6: test_discovery_supports_code_in_lib_dir
def test_discovery_supports_code_in_lib_dir(self):
self.session.startDir = support_file('scenario/package_in_lib')
event = events.LoadFromNamesEvent(self.loader, [], None)
result = self.session.hooks.loadTestsFromNames(event)
assert isinstance(result, self.loader.suiteClass)
self.assertEqual(len(result._tests), 1)
self.assertEqual(len(self.watcher.called), 1)
self.assertEqual(self.watcher.called[0].module.__name__, 'tests')
开发者ID:JNRowe,项目名称:nose2,代码行数:8,代码来源:test_discovery_loader.py
示例7: test_can_discover_test_modules_in_packages
def test_can_discover_test_modules_in_packages(self):
self.session.startDir = support_file('scenario/tests_in_package')
event = events.LoadFromNamesEvent(self.loader, [], None)
result = self.session.hooks.loadTestsFromNames(event)
assert isinstance(result, self.loader.suiteClass)
self.assertEqual(len(result._tests), 1)
self.assertEqual(len(self.watcher.called), 1)
self.assertEqual(self.watcher.called[0].module.__name__,
'pkg1.test.test_things')
开发者ID:JNRowe,项目名称:nose2,代码行数:9,代码来源:test_discovery_loader.py
示例8: test_flatten_respects_module_fixtures
def test_flatten_respects_module_fixtures(self):
sys.path.append(support_file('scenario/module_fixtures'))
import test_mf_testcase as mod
suite = unittest.TestSuite()
suite.addTest(mod.Test('test_1'))
suite.addTest(mod.Test('test_2'))
flat = list(self.plugin._flatten(suite))
self.assertEqual(flat, ['test_mf_testcase'])
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:10,代码来源:test_mp_plugin.py
示例9: run_with_junitxml_loaded
def run_with_junitxml_loaded(self, scenario, *args):
work_dir = os.getcwd()
test_dir = support_file(*scenario)
junit_report = os.path.join(work_dir, 'nose2-junit.xml')
proc = self.runIn(work_dir,
'-s%s' % test_dir,
'--plugin=nose2.plugins.junitxml',
'-v',
*args)
return junit_report, proc
开发者ID:jrast,项目名称:nose2,代码行数:11,代码来源:test_junitxml_plugin.py
示例10: test_flatten_without_fixtures
def test_flatten_without_fixtures(self):
sys.path.append(support_file('scenario/slow'))
import test_slow as mod
suite = unittest.TestSuite()
suite.addTest(mod.TestSlow('test_ok'))
suite.addTest(mod.TestSlow('test_fail'))
suite.addTest(mod.TestSlow('test_err'))
flat = list(self.plugin._flatten(suite))
self.assertEqual(len(flat), 3)
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:11,代码来源:test_mp_plugin.py
示例11: test_match_path_event_can_prevent_discovery
def test_match_path_event_can_prevent_discovery(self):
class NoTestsForYou(events.Plugin):
def matchPath(self, event):
event.handled = True
return False
mp = NoTestsForYou(session=self.session)
mp.register()
self.session.startDir = support_file('scenario/tests_in_package')
event = events.LoadFromNamesEvent(self.loader, [], None)
result = self.session.hooks.loadTestsFromNames(event)
assert isinstance(result, self.loader.suiteClass)
self.assertEqual(len(result._tests), 0)
self.assertEqual(len(self.watcher.called), 0)
开发者ID:JNRowe,项目名称:nose2,代码行数:13,代码来源:test_discovery_loader.py
示例12: test_run
def test_run(self):
# ensure there is no .coverage file at the start of test
reportfile = support_file('scenario/test_with_module/.coverage')
try:
os.remove(reportfile)
except OSError:
pass
proc = self.runIn(
'scenario/test_with_module',
'-v',
'--with-coverage',
'--coverage=lib/'
)
self.assertProcOutputPattern(proc, 'lib', '\s+8\s+5\s+38%')
self.assertTrue(os.path.exists(reportfile))
开发者ID:hugovk,项目名称:nose2,代码行数:16,代码来源:test_coverage.py
示例13: test_handle_file_event_can_add_tests
def test_handle_file_event_can_add_tests(self):
class TextTest(TestCase):
def test(self):
pass
class TestsInText(events.Plugin):
def handleFile(self, event):
if event.path.endswith('.txt'):
event.extraTests.append(TextTest('test'))
mp = TestsInText(session=self.session)
mp.register()
self.session.startDir = support_file('scenario/tests_in_package')
event = events.LoadFromNamesEvent(self.loader, [], None)
result = self.session.hooks.loadTestsFromNames(event)
assert isinstance(result, self.loader.suiteClass)
self.assertEqual(len(result._tests), 2)
self.assertEqual(len(self.watcher.called), 1)
开发者ID:JNRowe,项目名称:nose2,代码行数:16,代码来源:test_discovery_loader.py
示例14: run_with_junitxml_loaded
def run_with_junitxml_loaded(self, scenario, *args):
work_dir = os.getcwd()
test_dir = support_file(*scenario)
junit_report = os.path.join(work_dir, 'nose2-junit.xml')
config = os.path.join(test_dir, 'unittest.cfg')
config_args = ()
if os.path.exists(junit_report):
os.remove(junit_report)
if os.path.exists(config):
config_args = ('-c', config)
proc = self.runIn(work_dir,
'-s%s' % test_dir,
'--plugin=nose2.plugins.junitxml',
'-v',
*(config_args + args))
return junit_report, proc
开发者ID:NextThought,项目名称:nose2,代码行数:16,代码来源:test_junitxml_plugin.py
示例15: test_flatten_respects_class_fixtures
def test_flatten_respects_class_fixtures(self):
sys.path.append(support_file('scenario/class_fixtures'))
import test_cf_testcase as mod
suite = unittest.TestSuite()
suite.addTest(mod.Test('test_1'))
suite.addTest(mod.Test('test_2'))
suite.addTest(mod.Test2('test_1'))
suite.addTest(mod.Test2('test_2'))
suite.addTest(mod.Test3('test_3'))
flat = list(self.plugin._flatten(suite))
self.assertEqual(flat, ['test_cf_testcase.Test2.test_1',
'test_cf_testcase.Test2.test_2',
'test_cf_testcase.Test',
'test_cf_testcase.Test3',
])
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:17,代码来源:test_mp_plugin.py
示例16: test_start_directory_inside_package
def test_start_directory_inside_package(self):
proc = self.runIn(
'scenario/doctests/doctests_pkg1',
'-v',
'--plugin=nose2.plugins.doctests',
'--with-doctest',
'-t',
support_file('scenario/doctests')
)
self.assertTestRunOutputMatches(proc, stderr='Ran 3 tests')
self.assertTestRunOutputMatches(
proc, stderr='Doctest: doctests_pkg1.docs1 ... ok')
self.assertTestRunOutputMatches(
proc, stderr='Doctest: docs1.rst ... ok')
self.assertTestRunOutputMatches(
proc, stderr='Doctest: docs1.txt ... ok')
self.assertEqual(proc.poll(), 0)
开发者ID:abetkin,项目名称:nose2,代码行数:17,代码来源:test_doctests_plugin.py
示例17: setUp
def setUp(self):
self.s = session.Session()
self.s.loadConfigFiles(support_file('cfg', 'a.cfg'),
support_file('cfg', 'b.cfg'))
sys.path.insert(0, support_file('lib'))
开发者ID:hugovk,项目名称:nose2,代码行数:5,代码来源:test_session.py
示例18: setUp
def setUp(self):
self.s = session.Session()
self.s.loadConfigFiles(support_file("cfg", "a.cfg"), support_file("cfg", "b.cfg"))
sys.path.insert(0, support_file("lib"))
开发者ID:Gustry,项目名称:QGIS,代码行数:4,代码来源:test_session.py
示例19: setUp
def setUp(self):
for m in [m for m in sys.modules if m.startswith('pkgegg')]:
del sys.modules[m]
self.egg_path = support_file('scenario/tests_in_unzipped_eggs/pkgunegg-0.0.0-py2.7.egg')
sys.path.append(self.egg_path)
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:5,代码来源:test_eggdiscovery_loader.py
示例20: test_name_from_path
def test_name_from_path(self):
self.assertEqual(
util.name_from_path(support_file('scenario/tests_in_package/pkg1/test/test_things.py')), 'pkg1.test.test_things')
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:3,代码来源:test_util.py
注:本文中的nose2.tests._common.support_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论