make the parametrizing of tests nicer for integration tests

This commit is contained in:
Dave Halter
2014-04-14 17:07:34 +02:00
parent b81eb9f8b3
commit 62bd8bd8ef
2 changed files with 10 additions and 5 deletions

View File

@@ -57,7 +57,8 @@ def pytest_generate_tests(metafunc):
if thirdparty:
cases.extend(run.collect_dir_tests(
os.path.join(base_dir, 'thirdparty'), test_files, True))
metafunc.parametrize('case', cases)
ids = ["%s:%s" % (c.module_name, c.line_nr_test) for c in cases]
metafunc.parametrize('case', cases, ids=ids)
if 'refactor_case' in metafunc.fixturenames:
base_dir = metafunc.config.option.refactor_case_dir
metafunc.parametrize(

View File

@@ -139,12 +139,16 @@ class IntegrationTestCase(object):
@property
def module_name(self):
return re.sub('.*/|\.py', '', self.path)
return re.sub('.*/|\.py$', '', self.path)
@property
def line_nr_test(self):
"""The test is always defined on the line before."""
return self.line_nr - 1
def __repr__(self):
name = os.path.basename(self.path) if self.path else None
return '<%s: %s:%s:%s>' % (self.__class__.__name__,
name, self.line_nr - 1, self.line.rstrip())
return '<%s: %s:%s:%s>' % (self.__class__.__name__, self.module_name,
self.line_nr_test, self.line.rstrip())
def script(self):
return jedi.Script(self.source, self.line_nr, self.column, self.path)