introduce new --testpkg importpath option, add more meat to draft release announcement

This commit is contained in:
holger krekel
2010-11-06 22:17:33 +01:00
parent 1a7f2e77e8
commit 707775dcfa
7 changed files with 204 additions and 54 deletions

View File

@@ -5,7 +5,7 @@ see http://pytest.org for documentation and details
(c) Holger Krekel and others, 2004-2010
"""
__version__ = '2.0.0.dev19'
__version__ = '2.0.0.dev20'
__all__ = ['config', 'cmdline']

View File

@@ -9,8 +9,8 @@ cutdir = py.path.local(pytest.__file__).dirpath()
def pytest_addoption(parser):
group = parser.getgroup("terminal reporting")
group._addoption('--funcargs',
group = parser.getgroup("general")
group.addoption('--funcargs',
action="store_true", dest="showfuncargs", default=False,
help="show available function arguments, sorted by plugin")

View File

@@ -31,6 +31,8 @@ def pytest_addoption(parser):
group.addoption('--collectonly',
action="store_true", dest="collectonly",
help="only collect tests, don't execute them."),
group.addoption('--pyargs', action="store_true",
help="try to interpret all arguments as python packages.")
group.addoption("--ignore", action="append", metavar="path",
help="ignore path during collection (multi-allowed).")
group.addoption('--confcutdir', dest="confcutdir", default=None,
@@ -429,12 +431,29 @@ class Collection(FSCollector):
ihook.pytest_collect_directory(path=path, parent=self)
return True
def _tryconvertpyarg(self, x):
try:
mod = __import__(x, None, None, ['__doc__'])
except ImportError:
return x
p = py.path.local(mod.__file__)
if p.purebasename == "__init__":
p = p.dirpath()
return p
def _parsearg(self, arg):
""" return (fspath, names) tuple after checking the file exists. """
arg = str(arg)
if self.config.option.pyargs:
arg = self._tryconvertpyarg(arg)
parts = str(arg).split("::")
path = self.fspath.join(parts[0], abs=True)
if not path.check():
raise pytest.UsageError("file not found: %s" %(path,))
if self.config.option.pyargs:
msg = "file or package not found: "
else:
msg = "file not found: "
raise pytest.UsageError(msg + arg)
parts[0] = path
return parts