flat is better than nested (cont'd):

- pytest.py is new module, making "python -m pytest" work always
- _pytest/*.py now contains core.py, hookspec and the plugins, no sub packages
This commit is contained in:
holger krekel 2010-11-13 11:10:45 +01:00
parent 2e4e9eb745
commit 929291775e
62 changed files with 181 additions and 168 deletions

View File

@ -3,7 +3,7 @@ support for presented detailed information in failing assertions.
""" """
import py import py
import sys import sys
from pytest.plugin.monkeypatch import monkeypatch from _pytest.monkeypatch import monkeypatch
def pytest_addoption(parser): def pytest_addoption(parser):
group = parser.getgroup("debugconfig") group = parser.getgroup("debugconfig")

View File

@ -2,7 +2,7 @@
import py import py
import sys, os import sys, os
from pytest.main import PluginManager from _pytest.core import PluginManager
import pytest import pytest
def pytest_cmdline_parse(pluginmanager, args): def pytest_cmdline_parse(pluginmanager, args):

View File

@ -6,8 +6,7 @@ All else is in pytest/plugin.
import sys, os import sys, os
import inspect import inspect
import py 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: " assert py.__version__.split(".")[:2] >= ['2', '0'], ("installation problem: "
"%s is too old, remove or upgrade 'py'" % (py.__version__)) "%s is too old, remove or upgrade 'py'" % (py.__version__))
@ -206,6 +205,7 @@ class PluginManager(object):
self.consider_module(mod) self.consider_module(mod)
def pytest_plugin_registered(self, plugin): def pytest_plugin_registered(self, plugin):
import pytest
dic = self.call_plugin(plugin, "pytest_namespace", {}) or {} dic = self.call_plugin(plugin, "pytest_namespace", {}) or {}
if dic: if dic:
self._setns(pytest, dic) self._setns(pytest, dic)
@ -216,6 +216,7 @@ class PluginManager(object):
{'config': self._config}) {'config': self._config})
def _setns(self, obj, dic): def _setns(self, obj, dic):
import pytest
for name, value in dic.items(): for name, value in dic.items():
if isinstance(value, dict): if isinstance(value, dict):
mod = getattr(obj, name, None) mod = getattr(obj, name, None)
@ -225,14 +226,13 @@ class PluginManager(object):
sys.modules[modname] = mod sys.modules[modname] = mod
mod.__all__ = [] mod.__all__ = []
setattr(obj, name, mod) setattr(obj, name, mod)
#print "setns", mod, value obj.__all__.append(name)
self._setns(mod, value) self._setns(mod, value)
else: else:
#print "setting", name, value, "on", obj
setattr(obj, name, value) setattr(obj, name, value)
obj.__all__.append(name) obj.__all__.append(name)
#print "appending", name, "to", obj #if obj != pytest:
#pytest.__all__.append(name) # don't show in help(py.test) # pytest.__all__.append(name)
setattr(pytest, name, value) setattr(pytest, name, value)
def pytest_terminal_summary(self, terminalreporter): def pytest_terminal_summary(self, terminalreporter):
@ -300,7 +300,7 @@ def importplugin(importspec):
try: try:
if name.startswith("pytest_"): if name.startswith("pytest_"):
name = importspec[7:] name = importspec[7:]
return __import__("pytest.plugin.%s" %(name), None, None, '__doc__') return __import__("_pytest.%s" %(name), None, None, '__doc__')
except ImportError: except ImportError:
e = py.std.sys.exc_info()[1] e = py.std.sys.exc_info()[1]
if str(e).find(name) == -1: if str(e).find(name) == -1:
@ -411,7 +411,10 @@ class HookCaller:
self.trace.root.indent -= 1 self.trace.root.indent -= 1
return res return res
_preinit = [PluginManager(load=True)] # triggers default plugin importing _preinit = []
def _preloadplugins():
_preinit.append(PluginManager(load=True))
def main(args=None, plugins=None): def main(args=None, plugins=None):
""" returned exit code integer, after an in-process testing run """ returned exit code integer, after an in-process testing run
@ -446,5 +449,3 @@ def main(args=None, plugins=None):
class UsageError(Exception): class UsageError(Exception):
""" error in py.test usage or invocation""" """ error in py.test usage or invocation"""
if __name__ == '__main__':
raise SystemExit(main())

View File

@ -10,6 +10,9 @@ def find_toplevel(name):
lib = base/name lib = base/name
if lib.check(dir=1): if lib.check(dir=1):
return lib return lib
mod = base.join("%s.py" % name)
if mod.check(file=1):
return mod
raise LookupError(name) raise LookupError(name)
def pkgname(toplevel, rootpath, path): def pkgname(toplevel, rootpath, path):
@ -19,12 +22,14 @@ def pkgname(toplevel, rootpath, path):
def pkg_to_mapping(name): def pkg_to_mapping(name):
toplevel = find_toplevel(name) toplevel = find_toplevel(name)
name2src = {} name2src = {}
if toplevel.check(file=1): # module
name2src[toplevel.purebasename] = toplevel.read()
else: # package
for pyfile in toplevel.visit('*.py'): for pyfile in toplevel.visit('*.py'):
pkg = pkgname(name, toplevel, pyfile) pkg = pkgname(name, toplevel, pyfile)
name2src[pkg] = pyfile.read() name2src[pkg] = pyfile.read()
return name2src return name2src
def compress_mapping(mapping): def compress_mapping(mapping):
data = pickle.dumps(mapping, 2) data = pickle.dumps(mapping, 2)
data = zlib.compress(data, 9) data = zlib.compress(data, 9)
@ -60,7 +65,7 @@ def pytest_cmdline_main(config):
if genscript: if genscript:
script = generate_script( script = generate_script(
'import py; raise SystemExit(py.test.cmdline.main())', 'import py; raise SystemExit(py.test.cmdline.main())',
['py', 'pytest'], ['py', '_pytest', 'pytest'],
) )
genscript = py.path.local(genscript) genscript = py.path.local(genscript)

View File

@ -25,7 +25,7 @@ def pytest_addoption(parser):
def pytest_cmdline_main(config): def pytest_cmdline_main(config):
if config.option.version: 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" % sys.stderr.write("This is py.test version %s, imported from %s\n" %
(pytest.__version__, p)) (pytest.__version__, p))
return 0 return 0

View File

@ -139,9 +139,9 @@ def pytest_runtest_teardown(item):
""" called after ``pytest_runtest_call``. """ """ called after ``pytest_runtest_call``. """
def pytest_runtest_makereport(item, 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 for the given :py:class:`pytest.Item` and
:py:class:`pytest.plugin.runner.CallInfo`. :py:class:`_pytest.runner.CallInfo`.
""" """
pytest_runtest_makereport.firstresult = True 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): def pytest_report_header(config):

View File

@ -6,9 +6,9 @@ import re
import inspect import inspect
import time import time
from fnmatch import fnmatch from fnmatch import fnmatch
from pytest.plugin.session import Session from _pytest.session import Session
from py.builtin import print_ from py.builtin import print_
from pytest.main import HookRelay from _pytest.core import HookRelay
def pytest_addoption(parser): def pytest_addoption(parser):
group = parser.getgroup("pylib") group = parser.getgroup("pylib")
@ -492,7 +492,7 @@ class TmpTestdir:
if self.request.config.getvalue("notoolsonpath"): if self.request.config.getvalue("notoolsonpath"):
py.test.skip("--no-tools-on-path prevents running pexpect-spawn tests") py.test.skip("--no-tools-on-path prevents running pexpect-spawn tests")
basetemp = self.tmpdir.mkdir("pexpect") 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) cmd = "%s --basetemp=%s %s" % (invoke, basetemp, string)
return self.spawn(cmd, expect_timeout=expect_timeout) return self.spawn(cmd, expect_timeout=expect_timeout)

View File

@ -5,8 +5,8 @@ import sys
import pytest import pytest
from py._code.code import TerminalRepr 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): def pytest_addoption(parser):
group = parser.getgroup("general") group = parser.getgroup("general")
@ -611,7 +611,7 @@ class FuncargRequest:
This method is useful if you don't want to have a keyword/marker This method is useful if you don't want to have a keyword/marker
on all function invocations. 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(...)``. created by a call to ``py.test.mark.NAME(...)``.
""" """
if not isinstance(marker, py.test.mark.XYZ.__class__): if not isinstance(marker, py.test.mark.XYZ.__class__):
@ -712,7 +712,7 @@ class FuncargRequest:
raise self.LookupError(msg) raise self.LookupError(msg)
def showfuncargs(config): def showfuncargs(config):
from pytest.plugin.session import Session from _pytest.session import Session
session = Session(config) session = Session(config)
session.perform_collect() session.perform_collect()
if session.items: if session.items:

View File

@ -1,9 +1,9 @@
""" core implementation of testing process: init, session, runtest loop. """ """ core implementation of testing process: init, session, runtest loop. """
import py import py
import pytest import pytest, _pytest
import os, sys import os, sys
tracebackcutdir = py.path.local(pytest.__file__).dirpath() tracebackcutdir = py.path.local(_pytest.__file__).dirpath()
# exitcodes for the command line # exitcodes for the command line
EXIT_OK = 0 EXIT_OK = 0
@ -125,7 +125,8 @@ def compatproperty(name):
py.log._apiwarn("2.0", "use pytest.%s for " py.log._apiwarn("2.0", "use pytest.%s for "
"test collection and item classes" % name) "test collection and item classes" % name)
return getattr(pytest, name) return getattr(pytest, name)
return property(fget) return property(fget, None, None,
"deprecated attribute %r, use pytest.%s" % (name,name))
class Node(object): class Node(object):
""" base class for all Nodes in the collection tree. """ base class for all Nodes in the collection tree.

View File

@ -26,14 +26,16 @@ New Features
- new invocations through Python interpreter and from Python:: - new invocations through Python interpreter and from Python::
python -m pytest # on all pythons >= 2.7 python -m pytest # on all pythons >= 2.5
python -m pytest.main # on all pythons >= 2.5
or from a python program::
import pytest ; pytest.main(args, plugins) import pytest ; pytest.main(args, plugins)
see http://pytest.org/2.0.0/usage.html for details. see http://pytest.org/2.0.0/usage.html for details.
- new and better reporting information in assert expressions - 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. see http://pytest.org/2.0.0/assert.html for details.
@ -42,7 +44,7 @@ New Features
[pytest] [pytest]
norecursedirs = .hg data* # don't ever recurse in such dirs 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 see http://pytest.org/2.0.0/customize.html
@ -51,9 +53,10 @@ New Features
py.test --pyargs unittest 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. nose/unittest-style "dot" output.
Fixes Fixes
----------------------- -----------------------

View File

@ -1,6 +1,6 @@
# content of conftest.py # content of conftest.py
import py import pytest
def pytest_collect_file(path, parent): def pytest_collect_file(path, parent):
if path.ext == ".yml" and path.basename.startswith("test"): if path.ext == ".yml" and path.basename.startswith("test"):

View File

@ -2,7 +2,7 @@
creating and managing test function arguments creating and managing test function arguments
============================================================== ==============================================================
.. currentmodule:: pytest.plugin.python .. currentmodule:: _pytest.python
.. _`funcargs`: .. _`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 specific test function call. A request object is passed to a funcarg
factory and provides access to test configuration and context: factory and provides access to test configuration and context:
.. autoclass:: pytest.plugin.python.FuncargRequest() .. autoclass:: _pytest.python.FuncargRequest()
:members: function,cls,module,keywords,config :members: function,cls,module,keywords,config
.. _`useful caching and finalization helpers`: .. _`useful caching and finalization helpers`:

View File

@ -5,8 +5,8 @@ py.test: no-boilerplate testing with Python
.. note:: .. note::
version 2.0 introduces ``pytest`` as the main Python import name version 2.0 introduces ``pytest`` as the main Python import name
but for historic reasons ``py.test`` remains fully valid and but for compatibility reasons you may continue to use ``py.test``
represents the same package. in your test code.
Welcome to ``py.test`` documentation: Welcome to ``py.test`` documentation:

View File

@ -4,7 +4,7 @@
mark test functions with attributes mark test functions with attributes
================================================================= =================================================================
.. currentmodule:: pytest.plugin.mark .. currentmodule:: _pytest.mark
By using the ``py.test.mark`` helper you can instantiate By using the ``py.test.mark`` helper you can instantiate
decorators that will set named meta data on test functions. decorators that will set named meta data on test functions.

View File

@ -2,7 +2,7 @@
monkeypatching/mocking modules and environments monkeypatching/mocking modules and environments
================================================================ ================================================================
.. currentmodule:: pytest.plugin.monkeypatch .. currentmodule:: _pytest.monkeypatch
Sometimes tests need to invoke functionality which depends Sometimes tests need to invoke functionality which depends
on global settings or which invokes code which cannot be easily on global settings or which invokes code which cannot be easily

View File

@ -4,7 +4,7 @@ Running test written for nose
.. include:: links.inc .. include:: links.inc
py.test has basic support for running tests written for nose_. 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 Usage
------------- -------------

View File

@ -180,28 +180,28 @@ py.test default plugin reference
.. autosummary:: .. autosummary::
pytest.plugin.assertion _pytest.assertion
pytest.plugin.capture _pytest.capture
pytest.plugin.config _pytest.config
pytest.plugin.doctest _pytest.doctest
pytest.plugin.genscript _pytest.genscript
pytest.plugin.helpconfig _pytest.helpconfig
pytest.plugin.junitxml _pytest.junitxml
pytest.plugin.mark _pytest.mark
pytest.plugin.monkeypatch _pytest.monkeypatch
pytest.plugin.nose _pytest.nose
pytest.plugin.pastebin _pytest.pastebin
pytest.plugin.pdb _pytest.pdb
pytest.plugin.pytester _pytest.pytester
pytest.plugin.python _pytest.python
pytest.plugin.recwarn _pytest.recwarn
pytest.plugin.resultlog _pytest.resultlog
pytest.plugin.runner _pytest.runner
pytest.plugin.session _pytest.session
pytest.plugin.skipping _pytest.skipping
pytest.plugin.terminal _pytest.terminal
pytest.plugin.tmpdir _pytest.tmpdir
pytest.plugin.unittest _pytest.unittest
.. _`well specified hooks`: .. _`well specified hooks`:
@ -222,7 +222,7 @@ hook name itself you get useful errors.
initialisation, command line and configuration hooks initialisation, command line and configuration hooks
-------------------------------------------------------------------- --------------------------------------------------------------------
.. currentmodule:: pytest.hookspec .. currentmodule:: _pytest.hookspec
.. autofunction:: pytest_cmdline_parse .. autofunction:: pytest_cmdline_parse
.. autofunction:: pytest_namespace .. autofunction:: pytest_namespace
@ -243,11 +243,11 @@ All all runtest related hooks receive a :py:class:`pytest.Item` object.
.. autofunction:: pytest_runtest_makereport .. autofunction:: pytest_runtest_makereport
For deeper understanding you may look at the default implementation of For deeper understanding you may look at the default implementation of
these hooks in :py:mod:`pytest.plugin.runner` and maybe also these hooks in :py:mod:`_pytest.runner` and maybe also
in :py:mod:`pytest.plugin.pdb` which intercepts creation in :py:mod:`_pytest.pdb` which intercepts creation
of reports in order to drop to interactive debugging. 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. the reporting hook to print information about a test run.
collection hooks collection hooks
@ -284,35 +284,35 @@ test execution:
Reference of important objects involved in hooks Reference of important objects involved in hooks
=========================================================== ===========================================================
.. autoclass:: pytest.plugin.config.Config .. autoclass:: _pytest.config.Config
:members: :members:
.. autoclass:: pytest.plugin.config.Parser .. autoclass:: _pytest.config.Parser
:members: :members:
.. autoclass:: pytest.plugin.session.Node(name, parent) .. autoclass:: _pytest.session.Node(name, parent)
:members: :members:
.. ..
.. autoclass:: pytest.plugin.session.File(fspath, parent) .. autoclass:: _pytest.session.File(fspath, parent)
:members: :members:
.. autoclass:: pytest.plugin.session.Item(name, parent) .. autoclass:: _pytest.session.Item(name, parent)
:members: :members:
.. autoclass:: pytest.plugin.python.Module(name, parent) .. autoclass:: _pytest.python.Module(name, parent)
:members: :members:
.. autoclass:: pytest.plugin.python.Class(name, parent) .. autoclass:: _pytest.python.Class(name, parent)
:members: :members:
.. autoclass:: pytest.plugin.python.Function(name, parent) .. autoclass:: _pytest.python.Function(name, parent)
:members: :members:
.. autoclass:: pytest.plugin.runner.CallInfo .. autoclass:: _pytest.runner.CallInfo
:members: :members:
.. autoclass:: pytest.plugin.runner.TestReport .. autoclass:: _pytest.runner.TestReport
:members: :members:

View File

@ -7,6 +7,19 @@ Usage and Invocations
.. _cmdline: .. _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 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 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 Modifying Python traceback printing
---------------------------------------------- ----------------------------------------------

17
pytest.py Normal file
View File

@ -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

View File

@ -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

View File

@ -1,4 +0,0 @@
import pytest
if __name__ == '__main__':
raise SystemExit(pytest.main())

View File

@ -22,7 +22,7 @@ def main():
name='pytest', name='pytest',
description='py.test: simple powerful testing with Python', description='py.test: simple powerful testing with Python',
long_description = long_description, long_description = long_description,
version='2.0.0.dev25', version='2.0.0.dev26',
url='http://pytest.org', url='http://pytest.org',
license='MIT license', license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
@ -41,7 +41,8 @@ def main():
'Topic :: Utilities', 'Topic :: Utilities',
'Programming Language :: Python', 'Programming Language :: Python',
'Programming Language :: Python :: 3'], 'Programming Language :: Python :: 3'],
packages=['pytest', 'pytest.plugin', ], packages=['_pytest', ],
py_modules=['pytest'],
zip_safe=False, zip_safe=False,
) )

View File

@ -244,16 +244,30 @@ class TestInvocationVariants:
s = result.stdout.str() s = result.stdout.str()
assert 'MarkGenerator' in s assert 'MarkGenerator' in s
@pytest.mark.multi(source=['py.test', 'pytest']) def test_import_star_py_dot_test(self, testdir):
def test_import_star(self, testdir, source):
p = testdir.makepyfile(""" p = testdir.makepyfile("""
from %s import * from py.test import *
collect #collect
cmdline #cmdline
#Item
#assert collect.Item is Item
#assert collect.Collector is Collector
main main
skip skip
xfail 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) result = testdir.runpython(p)
assert result.ret == 0 assert result.ret == 0
@ -286,13 +300,6 @@ class TestInvocationVariants:
assert res.ret == 1 assert res.ret == 1
@py.test.mark.skipif("sys.version_info < (2,5)") @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): def test_python_pytest_package(self, testdir):
p1 = testdir.makepyfile("def test_pass(): pass") p1 = testdir.makepyfile("def test_pass(): pass")
res = testdir.run(py.std.sys.executable, "-m", "pytest", str(p1)) res = testdir.run(py.std.sys.executable, "-m", "pytest", str(p1))

View File

@ -1,8 +1,8 @@
import py import py
import pytest.plugin import _pytest
plugindir = py.path.local(pytest.plugin.__file__).dirpath() plugindir = py.path.local(_pytest.__file__).dirpath()
from pytest.main import default_plugins from _pytest.core import default_plugins
def pytest_collect_file(path, parent): def pytest_collect_file(path, parent):
if path.basename.startswith("pytest_") and path.ext == ".py": if path.basename.startswith("pytest_") and path.ext == ".py":

View File

@ -1,7 +1,7 @@
import sys import sys
import py import py
import pytest.plugin.assertion as plugin import _pytest.assertion as plugin
needsnewassert = py.test.mark.skipif("sys.version_info < (2,6)") needsnewassert = py.test.mark.skipif("sys.version_info < (2,6)")

View File

@ -1,5 +1,5 @@
import py, os, sys import py, os, sys
from pytest.plugin.capture import CaptureManager from _pytest.capture import CaptureManager
needsosdup = py.test.mark.xfail("not hasattr(os, 'dup')") needsosdup = py.test.mark.xfail("not hasattr(os, 'dup')")

View File

@ -1,4 +1,4 @@
from pytest.plugin.doctest import DoctestModule, DoctestTextfile from _pytest.doctest import DoctestModule, DoctestTextfile
import py import py
pytest_plugins = ["pytest_doctest"] pytest_plugins = ["pytest_doctest"]

View File

@ -22,7 +22,7 @@ def test_gen(testdir, anypython, standalone):
result = standalone.run(anypython, testdir, '--version') result = standalone.run(anypython, testdir, '--version')
assert result.ret == 0 assert result.ret == 0
result.stderr.fnmatch_lines([ result.stderr.fnmatch_lines([
"*imported from*mypytest" "*imported from*mypytest*"
]) ])
p = testdir.makepyfile("def test_func(): assert 0") p = testdir.makepyfile("def test_func(): assert 0")
result = standalone.run(anypython, testdir, p) result = standalone.run(anypython, testdir, p)

View File

@ -1,5 +1,5 @@
import py, pytest,os import py, pytest,os
from pytest.plugin.helpconfig import collectattr from _pytest.helpconfig import collectattr
def test_version(testdir): def test_version(testdir):
result = testdir.runpytest("--version") result = testdir.runpytest("--version")

View File

@ -1,5 +1,5 @@
import py import py
from pytest.plugin.mark import MarkGenerator as Mark from _pytest.mark import MarkGenerator as Mark
class TestMark: class TestMark:
def test_pytest_mark_notcallable(self): def test_pytest_mark_notcallable(self):

View File

@ -1,6 +1,6 @@
import os, sys import os, sys
import py import py
from pytest.plugin.monkeypatch import monkeypatch as MonkeyPatch from _pytest.monkeypatch import monkeypatch as MonkeyPatch
def test_setattr(): def test_setattr():
class A: class A:

View File

@ -1,7 +1,7 @@
import py import py
import os, sys import os, sys
from pytest.plugin.pytester import LineMatcher, LineComp, HookRecorder from _pytest.pytester import LineMatcher, LineComp, HookRecorder
from pytest.main import PluginManager from _pytest.core import PluginManager
def test_reportrecorder(testdir): def test_reportrecorder(testdir):
item = testdir.getitem("def test_func(): pass") item = testdir.getitem("def test_func(): pass")
@ -97,7 +97,7 @@ def test_hookrecorder_basic_no_args_hook():
def test_functional(testdir, linecomp): def test_functional(testdir, linecomp):
reprec = testdir.inline_runsource(""" reprec = testdir.inline_runsource("""
import py import py
from pytest.main import HookRelay, PluginManager from _pytest.core import HookRelay, PluginManager
pytest_plugins="pytester" pytest_plugins="pytester"
def test_func(_pytest): def test_func(_pytest):
class ApiClass: class ApiClass:

View File

@ -1,5 +1,5 @@
import pytest, py, sys import pytest, py, sys
from pytest.plugin import python as funcargs from _pytest import python as funcargs
class TestModule: class TestModule:
def test_failing_import(self, testdir): def test_failing_import(self, testdir):

View File

@ -1,5 +1,5 @@
import py import py
from pytest.plugin.recwarn import WarningsRecorder from _pytest.recwarn import WarningsRecorder
def test_WarningRecorder(recwarn): def test_WarningRecorder(recwarn):
showwarning = py.std.warnings.showwarning showwarning = py.std.warnings.showwarning

View File

@ -1,11 +1,11 @@
import py import py
import os import os
from pytest.plugin.resultlog import generic_path, ResultLog, \ from _pytest.resultlog import generic_path, ResultLog, \
pytest_configure, pytest_unconfigure pytest_configure, pytest_unconfigure
from pytest.plugin.session import Node, Item, FSCollector from _pytest.session import Node, Item, FSCollector
def test_generic_path(testdir): def test_generic_path(testdir):
from pytest.plugin.session import Session from _pytest.session import Session
config = testdir.parseconfig() config = testdir.parseconfig()
session = Session(config) session = Session(config)
p1 = Node('a', config=config, session=session) p1 = Node('a', config=config, session=session)

View File

@ -1,5 +1,5 @@
import py, sys import py, sys
from pytest.plugin import runner from _pytest import runner
from py._code.code import ReprExceptionInfo from py._code.code import ReprExceptionInfo
class TestSetupState: class TestSetupState:

View File

@ -1,8 +1,8 @@
import py import py
from pytest.plugin.skipping import MarkEvaluator, folded_skips from _pytest.skipping import MarkEvaluator, folded_skips
from pytest.plugin.skipping import pytest_runtest_setup from _pytest.skipping import pytest_runtest_setup
from pytest.plugin.runner import runtestprotocol from _pytest.runner import runtestprotocol
class TestEvaluator: class TestEvaluator:
def test_no_marker(self, testdir): def test_no_marker(self, testdir):

View File

@ -4,9 +4,9 @@ terminal reporting of the full testing process.
import pytest,py import pytest,py
import sys import sys
from pytest.plugin.terminal import TerminalReporter, \ from _pytest.terminal import TerminalReporter, \
CollectonlyReporter, repr_pythonversion, getreportopt CollectonlyReporter, repr_pythonversion, getreportopt
from pytest.plugin import runner from _pytest import runner
def basic_run_report(item): def basic_run_report(item):
runner.call_and_report(item, "setup", log=False) runner.call_and_report(item, "setup", log=False)

View File

@ -1,7 +1,7 @@
import py import py
from pytest.plugin.tmpdir import pytest_funcarg__tmpdir from _pytest.tmpdir import pytest_funcarg__tmpdir
from pytest.plugin.python import FuncargRequest from _pytest.python import FuncargRequest
def test_funcarg(testdir): def test_funcarg(testdir):
item = testdir.getitem(""" item = testdir.getitem("""

View File

@ -1,6 +1,6 @@
import pytest, py import pytest, py
from pytest.plugin.session import Session from _pytest.session import Session
class TestCollector: class TestCollector:
def test_collect_versus_item(self): def test_collect_versus_item(self):

View File

@ -1,6 +1,6 @@
import py import py
from pytest.plugin.config import getcfg, Config from _pytest.config import getcfg, Config
class TestParseIni: class TestParseIni:
def test_getcfg_and_config(self, tmpdir): def test_getcfg_and_config(self, tmpdir):

View File

@ -1,5 +1,5 @@
import py import py
from pytest.plugin.config import Conftest from _pytest.config import Conftest
def pytest_generate_tests(metafunc): def pytest_generate_tests(metafunc):
if "basedir" in metafunc.funcargnames: if "basedir" in metafunc.funcargnames:
@ -110,7 +110,7 @@ def test_conftest_global_import(testdir):
testdir.makeconftest("x=3") testdir.makeconftest("x=3")
p = testdir.makepyfile(""" p = testdir.makepyfile("""
import py import py
from pytest.plugin.config import Conftest from _pytest.config import Conftest
conf = Conftest() conf = Conftest()
mod = conf.importconftest(py.path.local("conftest.py")) mod = conf.importconftest(py.path.local("conftest.py"))
assert mod.x == 3 assert mod.x == 3

View File

@ -1,6 +1,6 @@
import py, os import py, os
from pytest.main import PluginManager, canonical_importname from _pytest.core import PluginManager, canonical_importname
from pytest.main import MultiCall, HookRelay, varnames from _pytest.core import MultiCall, HookRelay, varnames
class TestBootstrapping: class TestBootstrapping:
@ -560,7 +560,7 @@ class TestHookRelay:
class TestTracer: class TestTracer:
def test_simple(self): def test_simple(self):
from pytest.main import TagTracer from _pytest.core import TagTracer
rootlogger = TagTracer("[my] ") rootlogger = TagTracer("[my] ")
log = rootlogger.get("pytest") log = rootlogger.get("pytest")
log("hello") log("hello")
@ -574,7 +574,7 @@ class TestTracer:
assert l[1] == "[my] hello\n" assert l[1] == "[my] hello\n"
def test_indent(self): def test_indent(self):
from pytest.main import TagTracer from _pytest.core import TagTracer
rootlogger = TagTracer() rootlogger = TagTracer()
log = rootlogger.get("1") log = rootlogger.get("1")
l = [] l = []
@ -596,7 +596,7 @@ class TestTracer:
' line3', ' line4', ' line5', 'last'] ' line3', ' line4', ' line5', 'last']
def test_setprocessor(self): def test_setprocessor(self):
from pytest.main import TagTracer from _pytest.core import TagTracer
rootlogger = TagTracer() rootlogger = TagTracer()
log = rootlogger.get("1") log = rootlogger.get("1")
log2 = log.get("2") log2 = log.get("2")
@ -618,7 +618,7 @@ class TestTracer:
def test_setmyprocessor(self): def test_setmyprocessor(self):
from pytest.main import TagTracer from _pytest.core import TagTracer
rootlogger = TagTracer() rootlogger = TagTracer()
log = rootlogger.get("1") log = rootlogger.get("1")
log2 = log.get("2") log2 = log.get("2")

View File

@ -1,5 +1,5 @@
import py import py
from pytest.plugin import config as parseopt from _pytest import config as parseopt
from textwrap import dedent from textwrap import dedent
class TestParser: class TestParser:

View File

@ -52,5 +52,5 @@ commands=
minversion=2.0 minversion=2.0
plugins=pytester plugins=pytester
addopts=-rfx --pyargs addopts=-rfx --pyargs
rsyncdirs=pytest testing rsyncdirs=pytest.py _pytest testing