Shorter code, longer docstring
This commit is contained in:
parent
ee7e1c94d2
commit
d714c196a5
|
@ -1135,20 +1135,20 @@ class FixtureManager:
|
||||||
"""Split a nodeid into constituent 'parts'.
|
"""Split a nodeid into constituent 'parts'.
|
||||||
|
|
||||||
Node IDs are strings, and can be things like:
|
Node IDs are strings, and can be things like:
|
||||||
'',
|
''
|
||||||
'testing/code',
|
'testing/code'
|
||||||
'testing/code/test_excinfo.py'
|
'testing/code/test_excinfo.py'
|
||||||
'testing/code/test_excinfo.py::TestFormattedExcinfo::()'
|
'testing/code/test_excinfo.py::TestFormattedExcinfo::()'
|
||||||
|
|
||||||
|
Return values are lists e.g.
|
||||||
|
['']
|
||||||
|
['testing', 'code']
|
||||||
|
['testing', 'code', test_excinfo.py']
|
||||||
|
['testing', 'code', 'test_excinfo.py', 'TestFormattedExcinfo', '()']
|
||||||
"""
|
"""
|
||||||
if nodeid == '':
|
parts = nodeid.split(py.path.local.sep)
|
||||||
return []
|
# Replace single last element 'test_foo.py::Bar::()' with multiple elements 'test_foo.py', 'Bar', '()'
|
||||||
sep = py.path.local.sep
|
parts[-1:] = parts[-1].split("::")
|
||||||
parts = nodeid.split(sep)
|
|
||||||
last_part = parts[-1]
|
|
||||||
if '::' in last_part:
|
|
||||||
# Replace single last element 'test_foo.py::Bar::()' with multiple elements 'test_foo.py', 'Bar', '()'
|
|
||||||
parts[-1:] = last_part.split("::")
|
|
||||||
return parts
|
return parts
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in New Issue