fix issue544 by only removing "@NUM" at the end of a part (parts are

separated by "::") and if the part has an .py extension.

--HG--
branch : fix_initial_parsing
This commit is contained in:
holger krekel 2014-07-28 12:07:15 +02:00
parent 5ccd3f2fc5
commit 40eed363e8
3 changed files with 20 additions and 5 deletions

View File

@ -12,6 +12,8 @@ NEXT
- fix issue with detecting conftest files if the arguments contain
"::" node id specifications (copy pasted from "-v" output)
- fix issue544 by only removing "@NUM" at the end of "::" separated parts
and if the part has an ".py" extension
2.6
-----------------------------------

View File

@ -863,9 +863,13 @@ def getcfg(args, inibasenames):
def node_with_line_number(string):
split = string.split('[')
split[0] = re.sub(r'@\d+', '', split[0])
return '['.join(split)
newparts = []
for part in string.split("::"):
m = re.match(r'.*\.py@\d+$', part)
if m is not None:
part = part[:part.rfind("@")]
newparts.append(part)
return "::".join(newparts)
def setns(obj, dic):

View File

@ -146,8 +146,17 @@ class TestParser:
assert args.S == False
def test_parse_removes_line_number_from_positional_arguments(self, parser):
args = parser.parse(['path@2::func', 'path2@5::func2[param with @]'])
assert getattr(args, parseopt.FILE_OR_DIR) == ['path::func', 'path2::func2[param with @]']
args = parser.parse(['path.txt@2::item',
'path2.py::func2[param with .py@123]',
'path.py@123',
'hello/path.py@123',
])
assert getattr(args, parseopt.FILE_OR_DIR) == [
'path.txt@2::item',
'path2.py::func2[param with .py@123]',
'path.py',
'hello/path.py',
]
def test_parse_defaultgetter(self):
def defaultget(option):