From 3adf6687c9b3245fee5246be099870826acb63c7 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 19 Nov 2009 23:13:28 +0100 Subject: [PATCH] reintroduce py.test.cmdline.main() (alias for py.cmdline.pytest()) resolves issue #61 --HG-- branch : trunk --- doc/changelog.txt | 3 ++- doc/test/customize.txt | 10 ---------- py/__init__.py | 3 +++ py/impl/cmdline/pytest.py | 4 ++-- testing/pytest/test_outcome.py | 13 +++++++++++++ testing/root/test_api.py | 6 ------ 6 files changed, 20 insertions(+), 19 deletions(-) delete mode 100644 testing/root/test_api.py diff --git a/doc/changelog.txt b/doc/changelog.txt index e686ca6e6..6b83bd3da 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -1,12 +1,13 @@ Changes between 1.1.1 and 1.1.0 ===================================== +- re-introduce py.test.cmdline.main for backward compatibility + - fix a bug with path.check(versioned=True) for svn paths - try harder to have deprecation warnings for py.compat.* accesses report a correct location - Changes between 1.1.0 and 1.0.2 ===================================== diff --git a/doc/test/customize.txt b/doc/test/customize.txt index 542a72317..707811089 100644 --- a/doc/test/customize.txt +++ b/doc/test/customize.txt @@ -429,13 +429,3 @@ name. Given a filesystem ``fspath`` it is constructed as follows: * perform ``sys.path.insert(0, basedir)``. * import the root package as ``root`` - -* determine the fully qualified name for ``fspath`` by either: - - * calling ``root.__pkg__.getimportname(fspath)`` if the - ``__pkg__`` exists.` or - - * otherwise use the relative path of the module path to - the base dir and turn slashes into dots and strike - the trailing ``.py``. - diff --git a/py/__init__.py b/py/__init__.py index d40593100..8ab407234 100644 --- a/py/__init__.py +++ b/py/__init__.py @@ -68,6 +68,9 @@ py.apipkg.initpkg(__name__, dict( 'Function' : '.impl.test.pycollect:Function', '_fillfuncargs' : '.impl.test.funcargs:fillfuncargs', }, + 'cmdline': { + 'main' : '.impl.test.cmdline:main', # backward compat + }, }, # hook into the top-level standard library diff --git a/py/impl/cmdline/pytest.py b/py/impl/cmdline/pytest.py index 30322a3cf..fc460593c 100755 --- a/py/impl/cmdline/pytest.py +++ b/py/impl/cmdline/pytest.py @@ -1,5 +1,5 @@ #!/usr/bin/env python import py -def main(): - py.test.cmdline.main() +def main(args): + py.test.cmdline.main(args) diff --git a/testing/pytest/test_outcome.py b/testing/pytest/test_outcome.py index 146c61e8a..c6f2f8deb 100644 --- a/testing/pytest/test_outcome.py +++ b/testing/pytest/test_outcome.py @@ -56,3 +56,16 @@ def test_importorskip_imports_last_module_part(): ospath = py.test.importorskip("os.path") assert os.path == ospath + +def test_pytest_cmdline_main(testdir): + p = testdir.makepyfile(""" + import sys + sys.path.insert(0, %r) + import py + def test_hello(): + assert 1 + if __name__ == '__main__': + py.test.cmdline.main([__file__]) + """ % (str(py._dir.dirpath()))) + import subprocess + subprocess.check_call([sys.executable, str(p)]) diff --git a/testing/root/test_api.py b/testing/root/test_api.py deleted file mode 100644 index 033efe5c8..000000000 --- a/testing/root/test_api.py +++ /dev/null @@ -1,6 +0,0 @@ - -from py.test import raises -import py -import sys -import inspect -