diff --git a/pytest/plugin/__init__.py b/_pytest/__init__.py similarity index 100% rename from pytest/plugin/__init__.py rename to _pytest/__init__.py diff --git a/pytest/plugin/assertion.py b/_pytest/assertion.py similarity index 99% rename from pytest/plugin/assertion.py rename to _pytest/assertion.py index e0c17b015..71d26ab1c 100644 --- a/pytest/plugin/assertion.py +++ b/_pytest/assertion.py @@ -3,7 +3,7 @@ support for presented detailed information in failing assertions. """ import py import sys -from pytest.plugin.monkeypatch import monkeypatch +from _pytest.monkeypatch import monkeypatch def pytest_addoption(parser): group = parser.getgroup("debugconfig") diff --git a/pytest/plugin/capture.py b/_pytest/capture.py similarity index 100% rename from pytest/plugin/capture.py rename to _pytest/capture.py diff --git a/pytest/plugin/config.py b/_pytest/config.py similarity index 99% rename from pytest/plugin/config.py rename to _pytest/config.py index 68807d9ed..ba929eb28 100644 --- a/pytest/plugin/config.py +++ b/_pytest/config.py @@ -2,7 +2,7 @@ import py import sys, os -from pytest.main import PluginManager +from _pytest.core import PluginManager import pytest def pytest_cmdline_parse(pluginmanager, args): diff --git a/pytest/main.py b/_pytest/core.py similarity index 96% rename from pytest/main.py rename to _pytest/core.py index dabf441ea..5d4615ce2 100644 --- a/pytest/main.py +++ b/_pytest/core.py @@ -6,8 +6,7 @@ All else is in pytest/plugin. import sys, os import inspect import py -import pytest -from pytest import hookspec # the extension point definitions +from _pytest import hookspec # the extension point definitions assert py.__version__.split(".")[:2] >= ['2', '0'], ("installation problem: " "%s is too old, remove or upgrade 'py'" % (py.__version__)) @@ -206,6 +205,7 @@ class PluginManager(object): self.consider_module(mod) def pytest_plugin_registered(self, plugin): + import pytest dic = self.call_plugin(plugin, "pytest_namespace", {}) or {} if dic: self._setns(pytest, dic) @@ -216,6 +216,7 @@ class PluginManager(object): {'config': self._config}) def _setns(self, obj, dic): + import pytest for name, value in dic.items(): if isinstance(value, dict): mod = getattr(obj, name, None) @@ -225,14 +226,13 @@ class PluginManager(object): sys.modules[modname] = mod mod.__all__ = [] setattr(obj, name, mod) - #print "setns", mod, value + obj.__all__.append(name) self._setns(mod, value) else: - #print "setting", name, value, "on", obj setattr(obj, name, value) obj.__all__.append(name) - #print "appending", name, "to", obj - #pytest.__all__.append(name) # don't show in help(py.test) + #if obj != pytest: + # pytest.__all__.append(name) setattr(pytest, name, value) def pytest_terminal_summary(self, terminalreporter): @@ -300,7 +300,7 @@ def importplugin(importspec): try: if name.startswith("pytest_"): name = importspec[7:] - return __import__("pytest.plugin.%s" %(name), None, None, '__doc__') + return __import__("_pytest.%s" %(name), None, None, '__doc__') except ImportError: e = py.std.sys.exc_info()[1] if str(e).find(name) == -1: @@ -411,7 +411,10 @@ class HookCaller: self.trace.root.indent -= 1 return res -_preinit = [PluginManager(load=True)] # triggers default plugin importing +_preinit = [] + +def _preloadplugins(): + _preinit.append(PluginManager(load=True)) def main(args=None, plugins=None): """ returned exit code integer, after an in-process testing run @@ -446,5 +449,3 @@ def main(args=None, plugins=None): class UsageError(Exception): """ error in py.test usage or invocation""" -if __name__ == '__main__': - raise SystemExit(main()) diff --git a/pytest/plugin/doctest.py b/_pytest/doctest.py similarity index 100% rename from pytest/plugin/doctest.py rename to _pytest/doctest.py diff --git a/pytest/plugin/genscript.py b/_pytest/genscript.py similarity index 81% rename from pytest/plugin/genscript.py rename to _pytest/genscript.py index 6814610a5..8cb9c2f3a 100755 --- a/pytest/plugin/genscript.py +++ b/_pytest/genscript.py @@ -10,6 +10,9 @@ def find_toplevel(name): lib = base/name if lib.check(dir=1): return lib + mod = base.join("%s.py" % name) + if mod.check(file=1): + return mod raise LookupError(name) def pkgname(toplevel, rootpath, path): @@ -19,12 +22,14 @@ def pkgname(toplevel, rootpath, path): def pkg_to_mapping(name): toplevel = find_toplevel(name) name2src = {} - for pyfile in toplevel.visit('*.py'): - pkg = pkgname(name, toplevel, pyfile) - name2src[pkg] = pyfile.read() + if toplevel.check(file=1): # module + name2src[toplevel.purebasename] = toplevel.read() + else: # package + for pyfile in toplevel.visit('*.py'): + pkg = pkgname(name, toplevel, pyfile) + name2src[pkg] = pyfile.read() return name2src - def compress_mapping(mapping): data = pickle.dumps(mapping, 2) data = zlib.compress(data, 9) @@ -60,7 +65,7 @@ def pytest_cmdline_main(config): if genscript: script = generate_script( 'import py; raise SystemExit(py.test.cmdline.main())', - ['py', 'pytest'], + ['py', '_pytest', 'pytest'], ) genscript = py.path.local(genscript) diff --git a/pytest/plugin/helpconfig.py b/_pytest/helpconfig.py similarity index 99% rename from pytest/plugin/helpconfig.py rename to _pytest/helpconfig.py index d1f1ad118..ee1c3f5f7 100644 --- a/pytest/plugin/helpconfig.py +++ b/_pytest/helpconfig.py @@ -25,7 +25,7 @@ def pytest_addoption(parser): def pytest_cmdline_main(config): if config.option.version: - p = py.path.local(pytest.__file__).dirpath() + p = py.path.local(pytest.__file__) sys.stderr.write("This is py.test version %s, imported from %s\n" % (pytest.__version__, p)) return 0 diff --git a/pytest/hookspec.py b/_pytest/hookspec.py similarity index 97% rename from pytest/hookspec.py rename to _pytest/hookspec.py index ba06c479a..d4bf9f165 100644 --- a/pytest/hookspec.py +++ b/_pytest/hookspec.py @@ -139,9 +139,9 @@ def pytest_runtest_teardown(item): """ called after ``pytest_runtest_call``. """ def pytest_runtest_makereport(item, call): - """ return a :py:class:`pytest.plugin.runner.TestReport` object + """ return a :py:class:`_pytest.runner.TestReport` object for the given :py:class:`pytest.Item` and - :py:class:`pytest.plugin.runner.CallInfo`. + :py:class:`_pytest.runner.CallInfo`. """ pytest_runtest_makereport.firstresult = True @@ -181,7 +181,7 @@ def pytest_assertrepr_compare(config, op, left, right): """ # ------------------------------------------------------------------------- -# hooks for influencing reporting (invoked from pytest_terminal) +# hooks for influencing reporting (invoked from _pytest_terminal) # ------------------------------------------------------------------------- def pytest_report_header(config): diff --git a/pytest/plugin/junitxml.py b/_pytest/junitxml.py similarity index 100% rename from pytest/plugin/junitxml.py rename to _pytest/junitxml.py diff --git a/pytest/plugin/mark.py b/_pytest/mark.py similarity index 100% rename from pytest/plugin/mark.py rename to _pytest/mark.py diff --git a/pytest/plugin/monkeypatch.py b/_pytest/monkeypatch.py similarity index 100% rename from pytest/plugin/monkeypatch.py rename to _pytest/monkeypatch.py diff --git a/pytest/plugin/nose.py b/_pytest/nose.py similarity index 100% rename from pytest/plugin/nose.py rename to _pytest/nose.py diff --git a/pytest/plugin/pastebin.py b/_pytest/pastebin.py similarity index 100% rename from pytest/plugin/pastebin.py rename to _pytest/pastebin.py diff --git a/pytest/plugin/pdb.py b/_pytest/pdb.py similarity index 100% rename from pytest/plugin/pdb.py rename to _pytest/pdb.py diff --git a/pytest/plugin/pytester.py b/_pytest/pytester.py similarity index 99% rename from pytest/plugin/pytester.py rename to _pytest/pytester.py index 24c9c6fae..f634dccfc 100644 --- a/pytest/plugin/pytester.py +++ b/_pytest/pytester.py @@ -6,9 +6,9 @@ import re import inspect import time from fnmatch import fnmatch -from pytest.plugin.session import Session +from _pytest.session import Session from py.builtin import print_ -from pytest.main import HookRelay +from _pytest.core import HookRelay def pytest_addoption(parser): group = parser.getgroup("pylib") @@ -492,7 +492,7 @@ class TmpTestdir: if self.request.config.getvalue("notoolsonpath"): py.test.skip("--no-tools-on-path prevents running pexpect-spawn tests") basetemp = self.tmpdir.mkdir("pexpect") - invoke = self._getpybinargs("py.test")[0] + invoke = " ".join(map(str, self._getpybinargs("py.test"))) cmd = "%s --basetemp=%s %s" % (invoke, basetemp, string) return self.spawn(cmd, expect_timeout=expect_timeout) diff --git a/pytest/plugin/python.py b/_pytest/python.py similarity index 99% rename from pytest/plugin/python.py rename to _pytest/python.py index 3893f9726..93c8bbd0e 100644 --- a/pytest/plugin/python.py +++ b/_pytest/python.py @@ -5,8 +5,8 @@ import sys import pytest from py._code.code import TerminalRepr -cutdir = py.path.local(pytest.__file__).dirpath() - +import _pytest +cutdir = py.path.local(_pytest.__file__).dirpath() def pytest_addoption(parser): group = parser.getgroup("general") @@ -611,7 +611,7 @@ class FuncargRequest: This method is useful if you don't want to have a keyword/marker on all function invocations. - :arg marker: a :py:class:`pytest.plugin.mark.MarkDecorator` object + :arg marker: a :py:class:`_pytest.mark.MarkDecorator` object created by a call to ``py.test.mark.NAME(...)``. """ if not isinstance(marker, py.test.mark.XYZ.__class__): @@ -712,7 +712,7 @@ class FuncargRequest: raise self.LookupError(msg) def showfuncargs(config): - from pytest.plugin.session import Session + from _pytest.session import Session session = Session(config) session.perform_collect() if session.items: diff --git a/pytest/plugin/recwarn.py b/_pytest/recwarn.py similarity index 100% rename from pytest/plugin/recwarn.py rename to _pytest/recwarn.py diff --git a/pytest/plugin/resultlog.py b/_pytest/resultlog.py similarity index 100% rename from pytest/plugin/resultlog.py rename to _pytest/resultlog.py diff --git a/pytest/plugin/runner.py b/_pytest/runner.py similarity index 100% rename from pytest/plugin/runner.py rename to _pytest/runner.py diff --git a/pytest/plugin/session.py b/_pytest/session.py similarity index 98% rename from pytest/plugin/session.py rename to _pytest/session.py index 69366ae80..97cd20576 100644 --- a/pytest/plugin/session.py +++ b/_pytest/session.py @@ -1,9 +1,9 @@ """ core implementation of testing process: init, session, runtest loop. """ import py -import pytest +import pytest, _pytest import os, sys -tracebackcutdir = py.path.local(pytest.__file__).dirpath() +tracebackcutdir = py.path.local(_pytest.__file__).dirpath() # exitcodes for the command line EXIT_OK = 0 @@ -125,7 +125,8 @@ def compatproperty(name): py.log._apiwarn("2.0", "use pytest.%s for " "test collection and item classes" % name) return getattr(pytest, name) - return property(fget) + return property(fget, None, None, + "deprecated attribute %r, use pytest.%s" % (name,name)) class Node(object): """ base class for all Nodes in the collection tree. diff --git a/pytest/plugin/skipping.py b/_pytest/skipping.py similarity index 100% rename from pytest/plugin/skipping.py rename to _pytest/skipping.py diff --git a/pytest/plugin/standalonetemplate.py b/_pytest/standalonetemplate.py similarity index 100% rename from pytest/plugin/standalonetemplate.py rename to _pytest/standalonetemplate.py diff --git a/pytest/plugin/terminal.py b/_pytest/terminal.py similarity index 100% rename from pytest/plugin/terminal.py rename to _pytest/terminal.py diff --git a/pytest/plugin/tmpdir.py b/_pytest/tmpdir.py similarity index 100% rename from pytest/plugin/tmpdir.py rename to _pytest/tmpdir.py diff --git a/pytest/plugin/unittest.py b/_pytest/unittest.py similarity index 100% rename from pytest/plugin/unittest.py rename to _pytest/unittest.py diff --git a/doc/announce/release-2.0.0.txt b/doc/announce/release-2.0.0.txt index 16e250b44..0d6cb0371 100644 --- a/doc/announce/release-2.0.0.txt +++ b/doc/announce/release-2.0.0.txt @@ -26,14 +26,16 @@ New Features - new invocations through Python interpreter and from Python:: - python -m pytest # on all pythons >= 2.7 - python -m pytest.main # on all pythons >= 2.5 + python -m pytest # on all pythons >= 2.5 + + or from a python program:: + import pytest ; pytest.main(args, plugins) see http://pytest.org/2.0.0/usage.html for details. - new and better reporting information in assert expressions - which compare lists, sequences or strings. + if comparing lists, sequences or strings. see http://pytest.org/2.0.0/assert.html for details. @@ -42,7 +44,7 @@ New Features [pytest] norecursedirs = .hg data* # don't ever recurse in such dirs - addopts = -x --pyargs # add these options by default + addopts = -x --pyargs # add these command line options by default see http://pytest.org/2.0.0/customize.html @@ -51,9 +53,10 @@ New Features py.test --pyargs unittest -- add a new "-q" option which decreases verbosity and prints a more +- new "-q" option which decreases verbosity and prints a more nose/unittest-style "dot" output. + Fixes ----------------------- diff --git a/doc/example/nonpython/conftest.py b/doc/example/nonpython/conftest.py index b665ec3cb..dad316b75 100644 --- a/doc/example/nonpython/conftest.py +++ b/doc/example/nonpython/conftest.py @@ -1,6 +1,6 @@ # content of conftest.py -import py +import pytest def pytest_collect_file(path, parent): if path.ext == ".yml" and path.basename.startswith("test"): diff --git a/doc/funcargs.txt b/doc/funcargs.txt index 7b73e5ac2..fabe66114 100644 --- a/doc/funcargs.txt +++ b/doc/funcargs.txt @@ -2,7 +2,7 @@ creating and managing test function arguments ============================================================== -.. currentmodule:: pytest.plugin.python +.. currentmodule:: _pytest.python .. _`funcargs`: @@ -92,7 +92,7 @@ Each funcarg factory receives a **request** object which is tied to a specific test function call. A request object is passed to a funcarg factory and provides access to test configuration and context: -.. autoclass:: pytest.plugin.python.FuncargRequest() +.. autoclass:: _pytest.python.FuncargRequest() :members: function,cls,module,keywords,config .. _`useful caching and finalization helpers`: diff --git a/doc/index.txt b/doc/index.txt index 6037f6dd7..fd41792a3 100644 --- a/doc/index.txt +++ b/doc/index.txt @@ -5,8 +5,8 @@ py.test: no-boilerplate testing with Python .. note:: version 2.0 introduces ``pytest`` as the main Python import name - but for historic reasons ``py.test`` remains fully valid and - represents the same package. + but for compatibility reasons you may continue to use ``py.test`` + in your test code. Welcome to ``py.test`` documentation: diff --git a/doc/mark.txt b/doc/mark.txt index af629407d..a4809f97e 100644 --- a/doc/mark.txt +++ b/doc/mark.txt @@ -4,7 +4,7 @@ mark test functions with attributes ================================================================= -.. currentmodule:: pytest.plugin.mark +.. currentmodule:: _pytest.mark By using the ``py.test.mark`` helper you can instantiate decorators that will set named meta data on test functions. diff --git a/doc/monkeypatch.txt b/doc/monkeypatch.txt index b91b098d8..83ed3c510 100644 --- a/doc/monkeypatch.txt +++ b/doc/monkeypatch.txt @@ -2,7 +2,7 @@ monkeypatching/mocking modules and environments ================================================================ -.. currentmodule:: pytest.plugin.monkeypatch +.. currentmodule:: _pytest.monkeypatch Sometimes tests need to invoke functionality which depends on global settings or which invokes code which cannot be easily diff --git a/doc/nose.txt b/doc/nose.txt index 9edc2bf6c..8d785f5fa 100644 --- a/doc/nose.txt +++ b/doc/nose.txt @@ -4,7 +4,7 @@ Running test written for nose .. include:: links.inc py.test has basic support for running tests written for nose_. -This is implemented in :pymod:`pytest.plugin.nose`. +This is implemented in :pymod:`_pytest.nose`. Usage ------------- diff --git a/doc/plugins.txt b/doc/plugins.txt index e62104546..4308fad20 100644 --- a/doc/plugins.txt +++ b/doc/plugins.txt @@ -180,28 +180,28 @@ py.test default plugin reference .. autosummary:: - pytest.plugin.assertion - pytest.plugin.capture - pytest.plugin.config - pytest.plugin.doctest - pytest.plugin.genscript - pytest.plugin.helpconfig - pytest.plugin.junitxml - pytest.plugin.mark - pytest.plugin.monkeypatch - pytest.plugin.nose - pytest.plugin.pastebin - pytest.plugin.pdb - pytest.plugin.pytester - pytest.plugin.python - pytest.plugin.recwarn - pytest.plugin.resultlog - pytest.plugin.runner - pytest.plugin.session - pytest.plugin.skipping - pytest.plugin.terminal - pytest.plugin.tmpdir - pytest.plugin.unittest + _pytest.assertion + _pytest.capture + _pytest.config + _pytest.doctest + _pytest.genscript + _pytest.helpconfig + _pytest.junitxml + _pytest.mark + _pytest.monkeypatch + _pytest.nose + _pytest.pastebin + _pytest.pdb + _pytest.pytester + _pytest.python + _pytest.recwarn + _pytest.resultlog + _pytest.runner + _pytest.session + _pytest.skipping + _pytest.terminal + _pytest.tmpdir + _pytest.unittest .. _`well specified hooks`: @@ -222,7 +222,7 @@ hook name itself you get useful errors. initialisation, command line and configuration hooks -------------------------------------------------------------------- -.. currentmodule:: pytest.hookspec +.. currentmodule:: _pytest.hookspec .. autofunction:: pytest_cmdline_parse .. autofunction:: pytest_namespace @@ -243,11 +243,11 @@ All all runtest related hooks receive a :py:class:`pytest.Item` object. .. autofunction:: pytest_runtest_makereport For deeper understanding you may look at the default implementation of -these hooks in :py:mod:`pytest.plugin.runner` and maybe also -in :py:mod:`pytest.plugin.pdb` which intercepts creation +these hooks in :py:mod:`_pytest.runner` and maybe also +in :py:mod:`_pytest.pdb` which intercepts creation of reports in order to drop to interactive debugging. -The :py:mod:`pytest.plugin.terminal` reported specifically uses +The :py:mod:`_pytest.terminal` reported specifically uses the reporting hook to print information about a test run. collection hooks @@ -284,35 +284,35 @@ test execution: Reference of important objects involved in hooks =========================================================== -.. autoclass:: pytest.plugin.config.Config +.. autoclass:: _pytest.config.Config :members: -.. autoclass:: pytest.plugin.config.Parser +.. autoclass:: _pytest.config.Parser :members: -.. autoclass:: pytest.plugin.session.Node(name, parent) +.. autoclass:: _pytest.session.Node(name, parent) :members: .. - .. autoclass:: pytest.plugin.session.File(fspath, parent) + .. autoclass:: _pytest.session.File(fspath, parent) :members: - .. autoclass:: pytest.plugin.session.Item(name, parent) + .. autoclass:: _pytest.session.Item(name, parent) :members: - .. autoclass:: pytest.plugin.python.Module(name, parent) + .. autoclass:: _pytest.python.Module(name, parent) :members: - .. autoclass:: pytest.plugin.python.Class(name, parent) + .. autoclass:: _pytest.python.Class(name, parent) :members: - .. autoclass:: pytest.plugin.python.Function(name, parent) + .. autoclass:: _pytest.python.Function(name, parent) :members: -.. autoclass:: pytest.plugin.runner.CallInfo +.. autoclass:: _pytest.runner.CallInfo :members: -.. autoclass:: pytest.plugin.runner.TestReport +.. autoclass:: _pytest.runner.TestReport :members: diff --git a/doc/usage.txt b/doc/usage.txt index cb0696a18..446c1c51f 100644 --- a/doc/usage.txt +++ b/doc/usage.txt @@ -7,6 +7,19 @@ Usage and Invocations .. _cmdline: +calling pytest through ``python -m pytest`` +----------------------------------------------------- + +.. versionadded: 2.0 + +If you use Python-2.5 or above you can invoke testing through the +Python interpreter from the command line:: + + python -m pytest [...] + +This is equivalent to invoking the command line script ``py.test [...]`` +directly. + Getting help on version, option names, environment vars ----------------------------------------------------------- @@ -38,23 +51,6 @@ Import 'pkg' and use its filesystem location to find and run tests:: py.test --pyargs pkg # run all tests found below directory of pypkg -calling pytest through ``python -m pytest`` ------------------------------------------------------ - -.. versionadded: 2.0 - -You can invoke testing through the Python interpreter from the command line:: - - python -m pytest.main [...] - -Python2.7 and Python3 introduced specifying packages to "-m" so there -you can also type:: - - python -m pytest [...] - -All of these invocations are equivalent to the ``py.test [...]`` command line invocation. - - Modifying Python traceback printing ---------------------------------------------- diff --git a/pytest.py b/pytest.py new file mode 100644 index 000000000..45af8aa1a --- /dev/null +++ b/pytest.py @@ -0,0 +1,17 @@ +""" +unit and functional testing with Python. + +see http://pytest.org for documentation and details + +(c) Holger Krekel and others, 2004-2010 +""" +__version__ = '2.0.0.dev26' +__all__ = ['main'] + +from _pytest.core import main, UsageError, _preloadplugins +from _pytest import core as cmdline + +if __name__ == '__main__': # if run as a script or by 'python -m pytest' + raise SystemExit(main()) +else: + _preloadplugins() # to populate pytest.* namespace so help(pytest) works diff --git a/pytest/__init__.py b/pytest/__init__.py deleted file mode 100644 index 6942c3b52..000000000 --- a/pytest/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -""" -unit and functional testing with Python. - -see http://pytest.org for documentation and details - -(c) Holger Krekel and others, 2004-2010 -""" -__version__ = '2.0.0.dev25' - -__all__ = ['cmdline', 'collect', 'main'] - -from pytest import main as cmdline -UsageError = cmdline.UsageError -main = cmdline.main diff --git a/pytest/__main__.py b/pytest/__main__.py deleted file mode 100644 index 6dc62cd26..000000000 --- a/pytest/__main__.py +++ /dev/null @@ -1,4 +0,0 @@ -import pytest - -if __name__ == '__main__': - raise SystemExit(pytest.main()) diff --git a/setup.py b/setup.py index 6fe75ea48..8d26ebafd 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.0.0.dev25', + version='2.0.0.dev26', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], @@ -41,7 +41,8 @@ def main(): 'Topic :: Utilities', 'Programming Language :: Python', 'Programming Language :: Python :: 3'], - packages=['pytest', 'pytest.plugin', ], + packages=['_pytest', ], + py_modules=['pytest'], zip_safe=False, ) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 6b5d2c767..7ec7e3a50 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -244,16 +244,30 @@ class TestInvocationVariants: s = result.stdout.str() assert 'MarkGenerator' in s - @pytest.mark.multi(source=['py.test', 'pytest']) - def test_import_star(self, testdir, source): + def test_import_star_py_dot_test(self, testdir): p = testdir.makepyfile(""" - from %s import * - collect - cmdline + from py.test import * + #collect + #cmdline + #Item + #assert collect.Item is Item + #assert collect.Collector is Collector main skip xfail - """ % source) + """) + result = testdir.runpython(p) + assert result.ret == 0 + + def test_import_star_pytest(self, testdir): + p = testdir.makepyfile(""" + from pytest import * + #Item + #File + main + skip + xfail + """) result = testdir.runpython(p) assert result.ret == 0 @@ -286,13 +300,6 @@ class TestInvocationVariants: assert res.ret == 1 @py.test.mark.skipif("sys.version_info < (2,5)") - def test_python_pytest_main(self, testdir): - p1 = testdir.makepyfile("def test_pass(): pass") - res = testdir.run(py.std.sys.executable, "-m", "pytest.main", str(p1)) - assert res.ret == 0 - res.stdout.fnmatch_lines(["*1 passed*"]) - - @py.test.mark.skipif("sys.version_info < (2,7)") def test_python_pytest_package(self, testdir): p1 = testdir.makepyfile("def test_pass(): pass") res = testdir.run(py.std.sys.executable, "-m", "pytest", str(p1)) diff --git a/testing/plugin/conftest.py b/testing/plugin/conftest.py index 8df9abe4c..2777f0c12 100644 --- a/testing/plugin/conftest.py +++ b/testing/plugin/conftest.py @@ -1,8 +1,8 @@ import py -import pytest.plugin -plugindir = py.path.local(pytest.plugin.__file__).dirpath() -from pytest.main import default_plugins +import _pytest +plugindir = py.path.local(_pytest.__file__).dirpath() +from _pytest.core import default_plugins def pytest_collect_file(path, parent): if path.basename.startswith("pytest_") and path.ext == ".py": diff --git a/testing/plugin/test_assertion.py b/testing/plugin/test_assertion.py index d1a531a7c..b1daffb75 100644 --- a/testing/plugin/test_assertion.py +++ b/testing/plugin/test_assertion.py @@ -1,7 +1,7 @@ import sys import py -import pytest.plugin.assertion as plugin +import _pytest.assertion as plugin needsnewassert = py.test.mark.skipif("sys.version_info < (2,6)") diff --git a/testing/plugin/test_capture.py b/testing/plugin/test_capture.py index 825b883c6..89c757695 100644 --- a/testing/plugin/test_capture.py +++ b/testing/plugin/test_capture.py @@ -1,5 +1,5 @@ import py, os, sys -from pytest.plugin.capture import CaptureManager +from _pytest.capture import CaptureManager needsosdup = py.test.mark.xfail("not hasattr(os, 'dup')") diff --git a/testing/plugin/test_doctest.py b/testing/plugin/test_doctest.py index be62a8e86..7d4d5f80b 100644 --- a/testing/plugin/test_doctest.py +++ b/testing/plugin/test_doctest.py @@ -1,4 +1,4 @@ -from pytest.plugin.doctest import DoctestModule, DoctestTextfile +from _pytest.doctest import DoctestModule, DoctestTextfile import py pytest_plugins = ["pytest_doctest"] diff --git a/testing/plugin/test_genscript.py b/testing/plugin/test_genscript.py index 5b202adc0..0ac18015d 100644 --- a/testing/plugin/test_genscript.py +++ b/testing/plugin/test_genscript.py @@ -22,7 +22,7 @@ def test_gen(testdir, anypython, standalone): result = standalone.run(anypython, testdir, '--version') assert result.ret == 0 result.stderr.fnmatch_lines([ - "*imported from*mypytest" + "*imported from*mypytest*" ]) p = testdir.makepyfile("def test_func(): assert 0") result = standalone.run(anypython, testdir, p) diff --git a/testing/plugin/test_helpconfig.py b/testing/plugin/test_helpconfig.py index b8c7470d1..b08c1cdc1 100644 --- a/testing/plugin/test_helpconfig.py +++ b/testing/plugin/test_helpconfig.py @@ -1,5 +1,5 @@ import py, pytest,os -from pytest.plugin.helpconfig import collectattr +from _pytest.helpconfig import collectattr def test_version(testdir): result = testdir.runpytest("--version") diff --git a/testing/plugin/test_mark.py b/testing/plugin/test_mark.py index 96f5536c5..8aab88430 100644 --- a/testing/plugin/test_mark.py +++ b/testing/plugin/test_mark.py @@ -1,5 +1,5 @@ import py -from pytest.plugin.mark import MarkGenerator as Mark +from _pytest.mark import MarkGenerator as Mark class TestMark: def test_pytest_mark_notcallable(self): diff --git a/testing/plugin/test_monkeypatch.py b/testing/plugin/test_monkeypatch.py index c3adfecf7..d6cbdd0eb 100644 --- a/testing/plugin/test_monkeypatch.py +++ b/testing/plugin/test_monkeypatch.py @@ -1,6 +1,6 @@ import os, sys import py -from pytest.plugin.monkeypatch import monkeypatch as MonkeyPatch +from _pytest.monkeypatch import monkeypatch as MonkeyPatch def test_setattr(): class A: diff --git a/testing/plugin/test_pytester.py b/testing/plugin/test_pytester.py index 2d956360a..66ada43a6 100644 --- a/testing/plugin/test_pytester.py +++ b/testing/plugin/test_pytester.py @@ -1,7 +1,7 @@ import py import os, sys -from pytest.plugin.pytester import LineMatcher, LineComp, HookRecorder -from pytest.main import PluginManager +from _pytest.pytester import LineMatcher, LineComp, HookRecorder +from _pytest.core import PluginManager def test_reportrecorder(testdir): item = testdir.getitem("def test_func(): pass") @@ -97,7 +97,7 @@ def test_hookrecorder_basic_no_args_hook(): def test_functional(testdir, linecomp): reprec = testdir.inline_runsource(""" import py - from pytest.main import HookRelay, PluginManager + from _pytest.core import HookRelay, PluginManager pytest_plugins="pytester" def test_func(_pytest): class ApiClass: diff --git a/testing/plugin/test_python.py b/testing/plugin/test_python.py index 4fe295516..e8fe56210 100644 --- a/testing/plugin/test_python.py +++ b/testing/plugin/test_python.py @@ -1,5 +1,5 @@ import pytest, py, sys -from pytest.plugin import python as funcargs +from _pytest import python as funcargs class TestModule: def test_failing_import(self, testdir): diff --git a/testing/plugin/test_recwarn.py b/testing/plugin/test_recwarn.py index 6848fc1dd..d5bc6cfcc 100644 --- a/testing/plugin/test_recwarn.py +++ b/testing/plugin/test_recwarn.py @@ -1,5 +1,5 @@ import py -from pytest.plugin.recwarn import WarningsRecorder +from _pytest.recwarn import WarningsRecorder def test_WarningRecorder(recwarn): showwarning = py.std.warnings.showwarning diff --git a/testing/plugin/test_resultlog.py b/testing/plugin/test_resultlog.py index 0842fc32c..812f93657 100644 --- a/testing/plugin/test_resultlog.py +++ b/testing/plugin/test_resultlog.py @@ -1,11 +1,11 @@ import py import os -from pytest.plugin.resultlog import generic_path, ResultLog, \ +from _pytest.resultlog import generic_path, ResultLog, \ pytest_configure, pytest_unconfigure -from pytest.plugin.session import Node, Item, FSCollector +from _pytest.session import Node, Item, FSCollector def test_generic_path(testdir): - from pytest.plugin.session import Session + from _pytest.session import Session config = testdir.parseconfig() session = Session(config) p1 = Node('a', config=config, session=session) diff --git a/testing/plugin/test_runner.py b/testing/plugin/test_runner.py index 73a0c7247..6198e4fdf 100644 --- a/testing/plugin/test_runner.py +++ b/testing/plugin/test_runner.py @@ -1,5 +1,5 @@ import py, sys -from pytest.plugin import runner +from _pytest import runner from py._code.code import ReprExceptionInfo class TestSetupState: diff --git a/testing/plugin/test_skipping.py b/testing/plugin/test_skipping.py index 827ddf68c..81c60d257 100644 --- a/testing/plugin/test_skipping.py +++ b/testing/plugin/test_skipping.py @@ -1,8 +1,8 @@ import py -from pytest.plugin.skipping import MarkEvaluator, folded_skips -from pytest.plugin.skipping import pytest_runtest_setup -from pytest.plugin.runner import runtestprotocol +from _pytest.skipping import MarkEvaluator, folded_skips +from _pytest.skipping import pytest_runtest_setup +from _pytest.runner import runtestprotocol class TestEvaluator: def test_no_marker(self, testdir): diff --git a/testing/plugin/test_terminal.py b/testing/plugin/test_terminal.py index 371f04042..5843e37d0 100644 --- a/testing/plugin/test_terminal.py +++ b/testing/plugin/test_terminal.py @@ -4,9 +4,9 @@ terminal reporting of the full testing process. import pytest,py import sys -from pytest.plugin.terminal import TerminalReporter, \ +from _pytest.terminal import TerminalReporter, \ CollectonlyReporter, repr_pythonversion, getreportopt -from pytest.plugin import runner +from _pytest import runner def basic_run_report(item): runner.call_and_report(item, "setup", log=False) diff --git a/testing/plugin/test_tmpdir.py b/testing/plugin/test_tmpdir.py index 29c255664..66ba5d1aa 100644 --- a/testing/plugin/test_tmpdir.py +++ b/testing/plugin/test_tmpdir.py @@ -1,7 +1,7 @@ import py -from pytest.plugin.tmpdir import pytest_funcarg__tmpdir -from pytest.plugin.python import FuncargRequest +from _pytest.tmpdir import pytest_funcarg__tmpdir +from _pytest.python import FuncargRequest def test_funcarg(testdir): item = testdir.getitem(""" diff --git a/testing/test_collection.py b/testing/test_collection.py index 86a0bca25..819f53b4d 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -1,6 +1,6 @@ import pytest, py -from pytest.plugin.session import Session +from _pytest.session import Session class TestCollector: def test_collect_versus_item(self): diff --git a/testing/test_config.py b/testing/test_config.py index dfeb2f0c2..2fd509af6 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -1,6 +1,6 @@ import py -from pytest.plugin.config import getcfg, Config +from _pytest.config import getcfg, Config class TestParseIni: def test_getcfg_and_config(self, tmpdir): diff --git a/testing/test_conftest.py b/testing/test_conftest.py index 7755399a2..19221e09a 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -1,5 +1,5 @@ import py -from pytest.plugin.config import Conftest +from _pytest.config import Conftest def pytest_generate_tests(metafunc): if "basedir" in metafunc.funcargnames: @@ -110,7 +110,7 @@ def test_conftest_global_import(testdir): testdir.makeconftest("x=3") p = testdir.makepyfile(""" import py - from pytest.plugin.config import Conftest + from _pytest.config import Conftest conf = Conftest() mod = conf.importconftest(py.path.local("conftest.py")) assert mod.x == 3 diff --git a/testing/test_main.py b/testing/test_core.py similarity index 98% rename from testing/test_main.py rename to testing/test_core.py index 2b28b5496..a68d89f68 100644 --- a/testing/test_main.py +++ b/testing/test_core.py @@ -1,6 +1,6 @@ import py, os -from pytest.main import PluginManager, canonical_importname -from pytest.main import MultiCall, HookRelay, varnames +from _pytest.core import PluginManager, canonical_importname +from _pytest.core import MultiCall, HookRelay, varnames class TestBootstrapping: @@ -560,7 +560,7 @@ class TestHookRelay: class TestTracer: def test_simple(self): - from pytest.main import TagTracer + from _pytest.core import TagTracer rootlogger = TagTracer("[my] ") log = rootlogger.get("pytest") log("hello") @@ -574,7 +574,7 @@ class TestTracer: assert l[1] == "[my] hello\n" def test_indent(self): - from pytest.main import TagTracer + from _pytest.core import TagTracer rootlogger = TagTracer() log = rootlogger.get("1") l = [] @@ -596,7 +596,7 @@ class TestTracer: ' line3', ' line4', ' line5', 'last'] def test_setprocessor(self): - from pytest.main import TagTracer + from _pytest.core import TagTracer rootlogger = TagTracer() log = rootlogger.get("1") log2 = log.get("2") @@ -618,7 +618,7 @@ class TestTracer: def test_setmyprocessor(self): - from pytest.main import TagTracer + from _pytest.core import TagTracer rootlogger = TagTracer() log = rootlogger.get("1") log2 = log.get("2") diff --git a/testing/test_parseopt.py b/testing/test_parseopt.py index ab8f6ebca..9a7697625 100644 --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -1,5 +1,5 @@ import py -from pytest.plugin import config as parseopt +from _pytest import config as parseopt from textwrap import dedent class TestParser: diff --git a/tox.ini b/tox.ini index bddb1996a..bdae04cec 100644 --- a/tox.ini +++ b/tox.ini @@ -52,5 +52,5 @@ commands= minversion=2.0 plugins=pytester addopts=-rfx --pyargs -rsyncdirs=pytest testing +rsyncdirs=pytest.py _pytest testing