fix issue74 - propperly filter out missfit names in _tryconvertpyarg
This commit is contained in:
parent
ae54151467
commit
2c230f910d
|
@ -2,6 +2,7 @@ Changes between 2.1.3 and [next version]
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
- fix issue83: link to generated funcarg list
|
- fix issue83: link to generated funcarg list
|
||||||
|
- fix issue74: pyarg module names are now checked against imp.find_module false positives
|
||||||
|
|
||||||
Changes between 2.1.2 and 2.1.3
|
Changes between 2.1.2 and 2.1.3
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
|
@ -11,6 +11,8 @@ EXIT_TESTSFAILED = 1
|
||||||
EXIT_INTERRUPTED = 2
|
EXIT_INTERRUPTED = 2
|
||||||
EXIT_INTERNALERROR = 3
|
EXIT_INTERNALERROR = 3
|
||||||
|
|
||||||
|
name_re = py.std.re.compile("^[a-zA-Z_]\w*$")
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
parser.addini("norecursedirs", "directory patterns to avoid for recursion",
|
parser.addini("norecursedirs", "directory patterns to avoid for recursion",
|
||||||
type="args", default=('.*', 'CVS', '_darcs', '{arch}'))
|
type="args", default=('.*', 'CVS', '_darcs', '{arch}'))
|
||||||
|
@ -472,6 +474,13 @@ class Session(FSCollector):
|
||||||
mod = None
|
mod = None
|
||||||
path = [os.path.abspath('.')] + sys.path
|
path = [os.path.abspath('.')] + sys.path
|
||||||
for name in x.split('.'):
|
for name in x.split('.'):
|
||||||
|
# ignore anything thats not a propper name here
|
||||||
|
# else something like --pyargs will mess up '.'
|
||||||
|
# since imp.find_module will actually sometimes works for it
|
||||||
|
# but its supposed to be considered a filesystem path
|
||||||
|
# not a package
|
||||||
|
if name_re.match(name) is None:
|
||||||
|
return x
|
||||||
try:
|
try:
|
||||||
fd, mod, type_ = imp.find_module(name, path)
|
fd, mod, type_ = imp.find_module(name, path)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -408,6 +408,14 @@ class TestInvocationVariants:
|
||||||
result.stdout.fnmatch_lines([
|
result.stdout.fnmatch_lines([
|
||||||
"*2 passed*"
|
"*2 passed*"
|
||||||
])
|
])
|
||||||
|
|
||||||
|
result = testdir.runpytest("--pyargs", ".")
|
||||||
|
assert result.ret == 0
|
||||||
|
result.stdout.fnmatch_lines([
|
||||||
|
"*2 passed*"
|
||||||
|
])
|
||||||
|
|
||||||
|
monkeypatch.setenv('PYTHONPATH', testdir)
|
||||||
path.join('test_hello.py').remove()
|
path.join('test_hello.py').remove()
|
||||||
result = testdir.runpytest("--pyargs", "tpkg.test_hello")
|
result = testdir.runpytest("--pyargs", "tpkg.test_hello")
|
||||||
assert result.ret != 0
|
assert result.ret != 0
|
||||||
|
|
Loading…
Reference in New Issue