diff --git a/.hgignore b/.hgignore index c63f508d7..0e2e8e3b7 100644 --- a/.hgignore +++ b/.hgignore @@ -15,6 +15,7 @@ syntax:glob *.orig *~ +doc/_build build/ dist/ *.egg-info diff --git a/pytest/__init__.py b/pytest/__init__.py index 58937953e..e83ba61b9 100644 --- a/pytest/__init__.py +++ b/pytest/__init__.py @@ -1,28 +1,15 @@ """ -extensible functional and unit testing with Python. +py.test / pytest API for unit and functional testing with Python. (c) Holger Krekel and others, 2004-2010 """ __version__ = "2.0.0dev0" + +__all__ = ['collect', 'cmdline', 'config'] + import pytest._config +config = pytest._config.Config() from pytest import collect - -__all__ = ['collect', 'cmdline'] - -class cmdline: # compatibility py.test.cmdline.main == pytest.cmdline.main - @staticmethod - def main(args=None): - import sys - if args is None: - args = sys.argv[1:] - config = pytest._config.config_per_process = pytest._config.Config() - config.parse(args) - try: - exitstatus = config.hook.pytest_cmdline_main(config=config) - except config.Error: - e = sys.exc_info()[1] - sys.stderr.write("ERROR: %s\n" %(e.args[0],)) - exitstatus = EXIT_INTERNALERROR - return exitstatus +from pytest import main as cmdline def __main__(): raise SystemExit(cmdline.main()) diff --git a/pytest/_config.py b/pytest/_config.py index 33654e4e0..13aa07588 100644 --- a/pytest/_config.py +++ b/pytest/_config.py @@ -396,7 +396,5 @@ def onpytestaccess(): # which loads default plugins which add to py.test.* pass -# a default per-process instance of py.test configuration -config_per_process = Config() diff --git a/pytest/collect.py b/pytest/collect.py index 6a94cf2ee..456958916 100644 --- a/pytest/collect.py +++ b/pytest/collect.py @@ -3,6 +3,8 @@ test collection nodes, forming a tree, Items are leafs. """ import py +__all__ = ['Collector', 'Item', 'File', 'Directory'] + def configproperty(name): def fget(self): #print "retrieving %r property from %s" %(name, self.fspath) diff --git a/pytest/plugin/pytest_pytester.py b/pytest/plugin/pytest_pytester.py index 1f46aa60f..d1c5fed6d 100644 --- a/pytest/plugin/pytest_pytester.py +++ b/pytest/plugin/pytest_pytester.py @@ -223,14 +223,14 @@ class TmpTestdir: if not args: args = [self.tmpdir] from pytest import _config - oldconfig = _config.config_per_process # py.test.config + oldconfig = py.test.config try: - c = _config.config_per_process = py.test.config = pytestConfig() + c = py.test.config = pytestConfig() c.basetemp = oldconfig.mktemp("reparse", numbered=True) c.parse(args) return c finally: - _config.config_per_process = py.test.config = oldconfig + py.test.config = oldconfig def parseconfigure(self, *args): config = self.parseconfig(*args) diff --git a/pytest/plugin/pytest_python.py b/pytest/plugin/pytest_python.py index 35ebe1eda..53f9d9225 100644 --- a/pytest/plugin/pytest_python.py +++ b/pytest/plugin/pytest_python.py @@ -8,6 +8,10 @@ import pytest from pytest.collect import configproperty, warnoldcollect from py._code.code import TerminalRepr +import pytest +cutdir = py.path.local(pytest.__file__).dirpath() + + def pytest_addoption(parser): group = parser.getgroup("terminal reporting") group._addoption('--funcargs', @@ -327,7 +331,7 @@ class FunctionMixin(PyobjMixin): if ntraceback == traceback: ntraceback = ntraceback.cut(path=path) if ntraceback == traceback: - ntraceback = ntraceback.cut(excludepath=py._pydir) + ntraceback = ntraceback.cut(excludepath=cutdir) traceback = ntraceback.filter() return traceback diff --git a/pytest/plugin/pytest_terminal.py b/pytest/plugin/pytest_terminal.py index 1ed32a4f7..beeecc4fb 100644 --- a/pytest/plugin/pytest_terminal.py +++ b/pytest/plugin/pytest_terminal.py @@ -205,7 +205,7 @@ class TerminalReporter: self._sessionstarttime = py.std.time.time() verinfo = ".".join(map(str, sys.version_info[:3])) msg = "platform %s -- Python %s" % (sys.platform, verinfo) - msg += " -- pytest-%s" % (py.__version__) + msg += " -- pytest-%s" % (py.test.__version__) if self.config.option.verbose or self.config.option.debug or \ getattr(self.config.option, 'pastebin', None): msg += " -- " + str(sys.executable) diff --git a/pytest/pluginmanager.py b/pytest/pluginmanager.py index 9aaba12a9..ba39b8e7a 100644 --- a/pytest/pluginmanager.py +++ b/pytest/pluginmanager.py @@ -180,16 +180,14 @@ class PluginManager(object): if isinstance(value, dict): self._setns(getattr(obj, name), value) else: - #print "setting", name, value + #print "setting", name, value, "on", obj setattr(obj, name, value) - if hasattr(obj, '__all__'): - py.test.__all__.append(name) + obj.__all__.append(name) def pytest_plugin_registered(self, plugin): dic = self.call_plugin(plugin, "pytest_namespace", {}) or {} - import pytest if dic: - self._setns(pytest, dic) + self._setns(py.test, dic) if hasattr(self, '_config'): self.call_plugin(plugin, "pytest_addoption", {'parser': self._config._parser}) diff --git a/setup.py b/setup.py index a88fd2b1d..cf77bb3f4 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,7 @@ def main(): author='holger krekel, Guido Wesdorp, Carl Friedrich Bolz, Armin Rigo, Maciej Fijalkowski & others', author_email='holger at merlinux.eu', entry_points= make_entry_points(), + install_requires=['pylib>=1.3.9'], classifiers=['Development Status :: 6 - Mature', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', diff --git a/testing/plugin/test_pytest_genscript.py b/testing/plugin/test_pytest_genscript.py index 10da2e91d..c4e514ce1 100644 --- a/testing/plugin/test_pytest_genscript.py +++ b/testing/plugin/test_pytest_genscript.py @@ -1,6 +1,9 @@ import py, os, sys import subprocess +pytestmark = py.test.mark.xfail(run=False, + reason="XXX needs refactoring after pylib/pytest split") + def pytest_funcarg__standalone(request): return request.cached_setup(scope="module", setup=lambda: Standalone(request)) @@ -17,6 +20,7 @@ class Standalone: testdir.chdir() return testdir._run(anypython, self.script, *args) +@pytestmark # XXX bug in application of global markers to generated functions? def test_gen(testdir, anypython, standalone): result = standalone.run(anypython, testdir, '-h') assert result.ret == 0 diff --git a/testing/plugin/test_pytest_session.py b/testing/plugin/test_pytest_session.py index f1f39a94d..662e4f7a0 100644 --- a/testing/plugin/test_pytest_session.py +++ b/testing/plugin/test_pytest_session.py @@ -210,8 +210,8 @@ def test_plugin_specify(testdir): #) def test_plugin_already_exists(testdir): - config = testdir.parseconfig("-p", "default") - assert config.option.plugins == ['default'] + config = testdir.parseconfig("-p", "session") + assert config.option.plugins == ['session'] config.pluginmanager.do_configure(config) def test_exclude(testdir): diff --git a/tox.ini b/tox.ini index 78fcc1340..f6e84af43 100644 --- a/tox.ini +++ b/tox.ini @@ -4,21 +4,21 @@ envlist=py26,py27,py31,py27-xdist,py25,py24 [tox:hudson] distshare={toxworkdir}/distshare -sdistsrc={distshare}/py-* +sdistsrc={distshare}/pytest-* [testenv] changedir=testing commands= py.test -rfsxX --junitxml={envlogdir}/junit-{envname}.xml [] deps= + {distshare}/pylib-* pexpect nose -[testenv:py27] -basepython=python2.7 + [testenv:py27-xdist] basepython=python2.7 deps= - {distshare}/py-* + {distshare}/pylib-* {distshare}/pytest-xdist-* commands= py.test -n3 -rfsxX \ @@ -41,16 +41,13 @@ deps=docutils commands= {envpython} bin-for-dist/makepluginlist.py py.test [doc] -rsfxX --junitxml={envlogdir}/junit-{envname}s.xml --forcegen -[testenv:py25] -basepython=python2.5 -[testenv:py24] -basepython=python2.4 + [testenv:py31] -basepython=python3.1 -deps= +deps= {distshare}/pylib-* + [testenv:py32] -basepython=python3.2 deps= + #{distshare}/pytest-xdist-* #[testenv:pypy] #python=pypy-c