diff --git a/pytest/__init__.py b/pytest/__init__.py index bac1f5f4c..58937953e 100644 --- a/pytest/__init__.py +++ b/pytest/__init__.py @@ -3,16 +3,18 @@ extensible functional and unit testing with Python. (c) Holger Krekel and others, 2004-2010 """ __version__ = "2.0.0dev0" -import pytest.config +import pytest._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() + config = pytest._config.config_per_process = pytest._config.Config() config.parse(args) try: exitstatus = config.hook.pytest_cmdline_main(config=config) diff --git a/pytest/config.py b/pytest/_config.py similarity index 97% rename from pytest/config.py rename to pytest/_config.py index 53b88f4a2..33654e4e0 100644 --- a/pytest/config.py +++ b/pytest/_config.py @@ -215,16 +215,6 @@ class Conftest(object): return mod -def ensuretemp(string, dir=1): - """ (deprecated) return temporary directory path with - the given string as the trailing part. It is usually - better to use the 'tmpdir' function argument which will - take care to provide empty unique directories for each - test call even if the test is called multiple times. - """ - #py.log._apiwarn(">1.1", "use tmpdir function argument") - return py.test.config.ensuretemp(string, dir=dir) - class CmdOptions(object): """ holds cmdline options as attributes.""" def __init__(self, **kwargs): diff --git a/pytest/plugin/pytest_pytester.py b/pytest/plugin/pytest_pytester.py index 939ca0dbd..1f46aa60f 100644 --- a/pytest/plugin/pytest_pytester.py +++ b/pytest/plugin/pytest_pytester.py @@ -8,7 +8,7 @@ import re import inspect import time from fnmatch import fnmatch -from pytest.config import Config as pytestConfig +from pytest._config import Config as pytestConfig from pytest.plugin.pytest_session import Collection from py.builtin import print_ @@ -222,15 +222,15 @@ class TmpTestdir: """ this is used from tests that want to re-invoke parse(). """ if not args: args = [self.tmpdir] - from pytest import config - oldconfig = config.config_per_process # py.test.config + from pytest import _config + oldconfig = _config.config_per_process # py.test.config try: - c = config.config_per_process = py.test.config = pytestConfig() + c = _config.config_per_process = 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 + _config.config_per_process = py.test.config = oldconfig def parseconfigure(self, *args): config = self.parseconfig(*args) diff --git a/pytest/plugin/pytest_session.py b/pytest/plugin/pytest_session.py index f3c83ab0c..c251355cc 100644 --- a/pytest/plugin/pytest_session.py +++ b/pytest/plugin/pytest_session.py @@ -38,6 +38,7 @@ def pytest_configure(config): if config.getvalue("exitfirst"): config.option.maxfail = 1 + def pytest_cmdline_main(config): return Session(config).main() diff --git a/pytest/plugin/pytest_tmpdir.py b/pytest/plugin/pytest_tmpdir.py index 83907c7a6..79e1de257 100644 --- a/pytest/plugin/pytest_tmpdir.py +++ b/pytest/plugin/pytest_tmpdir.py @@ -8,7 +8,19 @@ usage example:: .. _`py.path.local`: ../../path.html """ -import py +import pytest + +def pytest_configure(config): + def ensuretemp(string, dir=1): + """ (deprecated) return temporary directory path with + the given string as the trailing part. It is usually + better to use the 'tmpdir' function argument which will + take care to provide empty unique directories for each + test call even if the test is called multiple times. + """ + #py.log._apiwarn(">1.1", "use tmpdir function argument") + return config.ensuretemp(string, dir=dir) + pytest.ensuretemp = ensuretemp def pytest_funcarg__tmpdir(request): """return a temporary directory path object diff --git a/pytest/pluginmanager.py b/pytest/pluginmanager.py index 12243a721..9aaba12a9 100644 --- a/pytest/pluginmanager.py +++ b/pytest/pluginmanager.py @@ -137,9 +137,9 @@ class PluginManager(object): mod = importplugin(modname) except KeyboardInterrupt: raise - #except py.test.skip.Exception: - # e = py.std.sys.exc_info()[1] - # self._hints.append("skipped plugin %r: %s" %((modname, e.msg))) + except py.test.skip.Exception: + e = py.std.sys.exc_info()[1] + self._hints.append("skipped plugin %r: %s" %((modname, e.msg))) else: check_old_use(mod, modname) self.register(mod) diff --git a/testing/plugin/test_pytest_tmpdir.py b/testing/plugin/test_pytest_tmpdir.py index d426dfb7b..0f676ec67 100644 --- a/testing/plugin/test_pytest_tmpdir.py +++ b/testing/plugin/test_pytest_tmpdir.py @@ -1,3 +1,5 @@ +import py + from pytest.plugin.pytest_tmpdir import pytest_funcarg__tmpdir from pytest.plugin.pytest_python import FuncargRequest @@ -7,3 +9,11 @@ def test_funcarg(testdir): assert p.check() bn = p.basename.strip("0123456789") assert bn.endswith("test_func") + +def test_ensuretemp(recwarn): + #py.test.deprecated_call(py.test.ensuretemp, 'hello') + d1 = py.test.ensuretemp('hello') + d2 = py.test.ensuretemp('hello') + assert d1 == d2 + assert d1.check(dir=1) + diff --git a/testing/test_config.py b/testing/test_config.py index 2c839866a..23d347dfa 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -121,13 +121,6 @@ def test_options_on_small_file_do_not_blow_up(testdir): ['--traceconfig'], ['-v'], ['-v', '-v']): runfiletest(opts + [path]) -def test_ensuretemp(recwarn): - #py.test.deprecated_call(py.test.ensuretemp, 'hello') - d1 = py.test.ensuretemp('hello') - d2 = py.test.ensuretemp('hello') - assert d1 == d2 - assert d1.check(dir=1) - def test_preparse_ordering(testdir, monkeypatch): pkg_resources = py.test.importorskip("pkg_resources") def my_iter(name): diff --git a/testing/test_conftest.py b/testing/test_conftest.py index 539f9fb9c..c509f6035 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -1,5 +1,5 @@ import py -from pytest.config import Conftest +from pytest._config import Conftest def pytest_generate_tests(metafunc): if "basedir" in metafunc.funcargnames: diff --git a/testing/test_parseopt.py b/testing/test_parseopt.py index a2f110f33..a74a8c061 100644 --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -1,5 +1,5 @@ import py -from pytest import config as parseopt +from pytest import _config as parseopt class TestParser: def test_init(self, capsys): diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 1971514a9..af20b210b 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -232,7 +232,7 @@ class TestBootstrapping: class TestPytestPluginInteractions: def test_addhooks_conftestplugin(self, testdir): - from pytest.config import Config + from pytest._config import Config newhooks = testdir.makepyfile(newhooks=""" def pytest_myhook(xyz): "new hook" @@ -283,7 +283,7 @@ class TestPytestPluginInteractions: ]) def test_do_option_conftestplugin(self, testdir): - from pytest.config import Config + from pytest._config import Config p = testdir.makepyfile(""" def pytest_addoption(parser): parser.addoption('--test123', action="store_true") @@ -312,7 +312,7 @@ class TestPytestPluginInteractions: ]) def test_do_option_postinitialize(self, testdir): - from pytest.config import Config + from pytest._config import Config config = Config() config.parse([]) config.pluginmanager.do_configure(config=config)