refine/fix isimportable-logic and ensure that 'tmpdir' has a python-importable name
--HG-- branch : trunk
This commit is contained in:
parent
8131f5bdc0
commit
ed7a2d2da3
|
@ -802,4 +802,8 @@ def autopath(globs=None):
|
|||
|
||||
|
||||
def isimportable(name):
|
||||
return name[0].isalpha() and name.isalnum()
|
||||
if name:
|
||||
if not (name[0].isalpha() or name[0] == '_'):
|
||||
return False
|
||||
name= name.replace("_", '')
|
||||
return not name or name.isalnum()
|
||||
|
|
|
@ -151,7 +151,7 @@ class Config(object):
|
|||
if not numbered:
|
||||
return basetemp.mkdir(basename)
|
||||
else:
|
||||
return py.path.local.make_numbered_dir(prefix=basename + "-",
|
||||
return py.path.local.make_numbered_dir(prefix=basename,
|
||||
keep=0, rootdir=basetemp, lock_timeout=None)
|
||||
|
||||
def getinitialnodes(self):
|
||||
|
|
|
@ -363,6 +363,17 @@ def test_pypkgdir_unimportable(tmpdir):
|
|||
assert subdir.ensure("xyz.py").pypkgpath() == subdir
|
||||
assert not pkg.pypkgpath()
|
||||
|
||||
def test_isimportable():
|
||||
from py._path.local import isimportable
|
||||
assert not isimportable("")
|
||||
assert isimportable("x")
|
||||
assert isimportable("x1")
|
||||
assert isimportable("x_1")
|
||||
assert isimportable("_")
|
||||
assert isimportable("_1")
|
||||
assert not isimportable("x-1")
|
||||
assert not isimportable("x:1")
|
||||
|
||||
def test_homedir():
|
||||
homedir = py.path.local._gethomedir()
|
||||
assert homedir.check(dir=1)
|
||||
|
|
|
@ -5,5 +5,5 @@ def test_funcarg(testdir):
|
|||
item = testdir.getitem("def test_func(tmpdir): pass")
|
||||
p = pytest_funcarg__tmpdir(FuncargRequest(item))
|
||||
assert p.check()
|
||||
bn = p.basename.strip("0123456789-")
|
||||
bn = p.basename.strip("0123456789")
|
||||
assert bn.endswith("test_func")
|
||||
|
|
Loading…
Reference in New Issue