diff --git a/CHANGELOG b/CHANGELOG index 93181409c..24148b1ea 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,10 +1,10 @@ Changes between 1.0.0b7 and 1.0.0b8 ===================================== -* pytest_unittest-plugin are now enabled by default +* pytest_unittest-plugin is now enabled by default * introduced pytest_keyboardinterrupt hook and - refined pytest_sessionfinish hooked. + refined pytest_sessionfinish hooked, added tests. * workaround a buggy logging module interaction ("closing already closed files"). Thanks to Sridhar Ratnakumar for triggering. @@ -13,9 +13,8 @@ Changes between 1.0.0b7 and 1.0.0b8 a dependency only a warning will be issued instead of exiting the testing process. -* docs: - - refined funcargs doc , use the term "factory" instead - of "provider" +* many improvements to docs: + - refined funcargs doc , use the term "factory" instead of "provider" - added a new talk/tutorial doc page - better download page - better plugin docstrings diff --git a/MANIFEST b/MANIFEST index 90db9231e..1ef10deee 100644 --- a/MANIFEST +++ b/MANIFEST @@ -28,7 +28,25 @@ doc/test/examples.txt doc/test/extend.txt doc/test/features.txt doc/test/funcargs.txt -doc/test/plugins.txt +doc/test/plugin/doctest.txt +doc/test/plugin/execnetcleanup.txt +doc/test/plugin/figleaf.txt +doc/test/plugin/hooklog.txt +doc/test/plugin/hookspec.txt +doc/test/plugin/index.txt +doc/test/plugin/iocapture.txt +doc/test/plugin/keyword.txt +doc/test/plugin/monkeypatch.txt +doc/test/plugin/pdb.txt +doc/test/plugin/pocoo.txt +doc/test/plugin/pytester.txt +doc/test/plugin/recwarn.txt +doc/test/plugin/restdoc.txt +doc/test/plugin/resultlog.txt +doc/test/plugin/runner.txt +doc/test/plugin/terminal.txt +doc/test/plugin/unittest.txt +doc/test/plugin/xfail.txt doc/test/quickstart.txt doc/test/talks.txt doc/test/test.txt @@ -340,6 +358,7 @@ py/test/plugin/pytest_unittest.py py/test/plugin/pytest_xfail.py py/test/plugin/test_pytest_runner.py py/test/plugin/test_pytest_runner_xunit.py +py/test/plugin/test_pytest_terminal.py py/test/pluginmanager.py py/test/pycollect.py py/test/session.py @@ -358,6 +377,7 @@ py/test/testing/test_conftesthandle.py py/test/testing/test_deprecated_api.py py/test/testing/test_funcargs.py py/test/testing/test_genitems.py +py/test/testing/test_install.py py/test/testing/test_outcome.py py/test/testing/test_parseopt.py py/test/testing/test_pickling.py diff --git a/doc/test/plugin/doctest.txt b/doc/test/plugin/doctest.txt index 445a6dbda..f430b4098 100644 --- a/doc/test/plugin/doctest.txt +++ b/doc/test/plugin/doctest.txt @@ -233,7 +233,7 @@ For your convenience here is also an inlined version of ``pytest_doctest.py``: "*test_txtfile_failing.txt:2: DocTestFailure" ]) -.. _`pytest_doctest.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_doctest.py +.. _`pytest_doctest.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_doctest.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/execnetcleanup.txt b/doc/test/plugin/execnetcleanup.txt index e99d093c5..ed360e9b5 100644 --- a/doc/test/plugin/execnetcleanup.txt +++ b/doc/test/plugin/execnetcleanup.txt @@ -79,7 +79,7 @@ For your convenience here is also an inlined version of ``pytest_execnetcleanup. """, "-s", "--debug") reprec.assertoutcome(passed=2) -.. _`pytest_execnetcleanup.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_execnetcleanup.py +.. _`pytest_execnetcleanup.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_execnetcleanup.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/figleaf.txt b/doc/test/plugin/figleaf.txt index ad4678108..c250a8768 100644 --- a/doc/test/plugin/figleaf.txt +++ b/doc/test/plugin/figleaf.txt @@ -103,7 +103,7 @@ For your convenience here is also an inlined version of ``pytest_figleaf.py``: ]) #print result.stdout.str() -.. _`pytest_figleaf.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_figleaf.py +.. _`pytest_figleaf.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_figleaf.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/hooklog.txt b/doc/test/plugin/hooklog.txt index 868c1ab89..86dfad847 100644 --- a/doc/test/plugin/hooklog.txt +++ b/doc/test/plugin/hooklog.txt @@ -65,7 +65,7 @@ For your convenience here is also an inlined version of ``pytest_hooklog.py``: assert s.find("ItemTestReport") != -1 assert s.find("sessionfinish") != -1 -.. _`pytest_hooklog.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_hooklog.py +.. _`pytest_hooklog.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_hooklog.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/iocapture.txt b/doc/test/plugin/iocapture.txt index bcf99dced..c8825e2a9 100644 --- a/doc/test/plugin/iocapture.txt +++ b/doc/test/plugin/iocapture.txt @@ -164,7 +164,7 @@ For your convenience here is also an inlined version of ``pytest_iocapture.py``: """) reprec.assertoutcome(passed=1) -.. _`pytest_iocapture.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_iocapture.py +.. _`pytest_iocapture.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_iocapture.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/keyword.txt b/doc/test/plugin/keyword.txt index c159c9b15..50ef85e06 100644 --- a/doc/test/plugin/keyword.txt +++ b/doc/test/plugin/keyword.txt @@ -103,7 +103,7 @@ For your convenience here is also an inlined version of ``pytest_keyword.py``: result = testdir.runpytest(p) assert result.stdout.fnmatch_lines(["*passed*"]) -.. _`pytest_keyword.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_keyword.py +.. _`pytest_keyword.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_keyword.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/monkeypatch.txt b/doc/test/plugin/monkeypatch.txt index 9ebef0f98..f28b0d7f8 100644 --- a/doc/test/plugin/monkeypatch.txt +++ b/doc/test/plugin/monkeypatch.txt @@ -182,7 +182,7 @@ For your convenience here is also an inlined version of ``pytest_monkeypatch.py` res = reprec.countoutcomes() assert tuple(res) == (1, 0, 0), res -.. _`pytest_monkeypatch.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_monkeypatch.py +.. _`pytest_monkeypatch.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_monkeypatch.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/pdb.txt b/doc/test/plugin/pdb.txt index 659319246..e1c4b3568 100644 --- a/doc/test/plugin/pdb.txt +++ b/doc/test/plugin/pdb.txt @@ -185,7 +185,7 @@ For your convenience here is also an inlined version of ``pytest_pdb.py``: if child.isalive(): child.wait() -.. _`pytest_pdb.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_pdb.py +.. _`pytest_pdb.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_pdb.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/pocoo.txt b/doc/test/plugin/pocoo.txt index 0dbc66e7d..c0fed7d8c 100644 Binary files a/doc/test/plugin/pocoo.txt and b/doc/test/plugin/pocoo.txt differ diff --git a/doc/test/plugin/pytester.txt b/doc/test/plugin/pytester.txt index 82d8607ec..880f0070d 100644 --- a/doc/test/plugin/pytester.txt +++ b/doc/test/plugin/pytester.txt @@ -18,6 +18,13 @@ XXX missing docstring the 'reportrecorder' test function argument ------------------------------------------- +XXX missing docstring +.. _`venv funcarg`: + + +the 'venv' test function argument +--------------------------------- + XXX missing docstring .. _`linecomp funcarg`: @@ -25,6 +32,13 @@ XXX missing docstring the 'linecomp' test function argument ------------------------------------- +XXX missing docstring +.. _`py_setup funcarg`: + + +the 'py_setup' test function argument +------------------------------------- + XXX missing docstring .. _`LineMatcher funcarg`: @@ -61,6 +75,7 @@ For your convenience here is also an inlined version of ``pytest_pytester.py``: import inspect from py.__.test.config import Config as pytestConfig import hookspec + import subprocess pytest_plugins = '_pytest' @@ -560,8 +575,108 @@ For your convenience here is also an inlined version of ``pytest_pytester.py``: assert result.stdout.fnmatch_lines([ "*1 passed*" ]) + + # + # experimental funcargs for venv/install-tests + # + + def pytest_funcarg__venv(request): + p = request.config.mktemp(request.function.__name__, numbered=True) + venv = VirtualEnv(str(p)) + venv.create() + return venv + + def pytest_funcarg__py_setup(request): + rootdir = py.path.local(py.__file__).dirpath().dirpath() + setup = rootdir.join('setup.py') + if not setup.check(): + py.test.skip("not found: %r" % setup) + return SetupBuilder(setup) + + class SetupBuilder: + def __init__(self, setup_path): + self.setup_path = setup_path + + def make_sdist(self, destdir=None): + temp = py.path.local.mkdtemp() + try: + args = ['python', str(self.setup_path), 'sdist', + '--dist-dir', str(temp)] + subprocess.check_call(args) + l = temp.listdir('py-*') + assert len(l) == 1 + sdist = l[0] + if destdir is None: + destdir = self.setup_path.dirpath('build') + assert destdir.check() + else: + destdir = py.path.local(destdir) + target = destdir.join(sdist.basename) + sdist.copy(target) + return target + finally: + temp.remove() + + # code taken from Ronny Pfannenschmidt's virtualenvmanager + + class VirtualEnv(object): + def __init__(self, path): + #XXX: supply the python executable + self.path = path + + def __repr__(self): + return "" %(self.path) + + def _cmd(self, name): + return os.path.join(self.path, 'bin', name) + + @property + def valid(self): + return os.path.exists(self._cmd('python')) + + def create(self, sitepackages=False): + args = ['virtualenv', self.path] + if not sitepackages: + args.append('--no-site-packages') + subprocess.check_call(args) + + def makegateway(self): + python = self._cmd('python') + return py.execnet.makegateway("popen//python=%s" %(python,)) + + def pcall(self, cmd, *args, **kw): + assert self.valid + return subprocess.call([ + self._cmd(cmd) + ] + list(args), + **kw) + + + def easy_install(self, *packages, **kw): + args = [] + if 'index' in kw: + index = kw['index'] + if isinstance(index, (list, tuple)): + for i in index: + args.extend(['-i', i]) + else: + args.extend(['-i', index]) + + args.extend(packages) + self.pcall('easy_install', *args) + + + @property + def has_pip(self): + return os.path.exists(self._cmd('pip')) + + def pip_install(self, *packages): + if not self.has_pip: + self.easy_install('pip') + + self.pcall('pip', *packages) -.. _`pytest_pytester.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_pytester.py +.. _`pytest_pytester.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_pytester.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/recwarn.txt b/doc/test/plugin/recwarn.txt index c09078890..4da2537ef 100644 --- a/doc/test/plugin/recwarn.txt +++ b/doc/test/plugin/recwarn.txt @@ -204,7 +204,7 @@ For your convenience here is also an inlined version of ``pytest_recwarn.py``: py.test.deprecated_call(dep_explicit, 0) py.test.deprecated_call(dep_explicit, 0) -.. _`pytest_recwarn.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_recwarn.py +.. _`pytest_recwarn.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_recwarn.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/restdoc.txt b/doc/test/plugin/restdoc.txt index b1b1ae015..35bd40636 100644 --- a/doc/test/plugin/restdoc.txt +++ b/doc/test/plugin/restdoc.txt @@ -524,7 +524,7 @@ For your convenience here is also an inlined version of ``pytest_restdoc.py``: assert not failed assert skipped <= 1 -.. _`pytest_restdoc.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_restdoc.py +.. _`pytest_restdoc.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_restdoc.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/resultlog.txt b/doc/test/plugin/resultlog.txt index 0d0d72900..d457369ec 100644 --- a/doc/test/plugin/resultlog.txt +++ b/doc/test/plugin/resultlog.txt @@ -274,7 +274,7 @@ For your convenience here is also an inlined version of ``pytest_resultlog.py``: "s *:test_skip", ]) -.. _`pytest_resultlog.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_resultlog.py +.. _`pytest_resultlog.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_resultlog.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/runner.txt b/doc/test/plugin/runner.txt index 4548cb0fe..6455c705c 100644 --- a/doc/test/plugin/runner.txt +++ b/doc/test/plugin/runner.txt @@ -297,7 +297,7 @@ For your convenience here is also an inlined version of ``pytest_runner.py``: col.setup() self.stack.append(col) -.. _`pytest_runner.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_runner.py +.. _`pytest_runner.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_runner.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/terminal.txt b/doc/test/plugin/terminal.txt index de1ea85e7..eec05cb58 100644 --- a/doc/test/plugin/terminal.txt +++ b/doc/test/plugin/terminal.txt @@ -425,7 +425,7 @@ For your convenience here is also an inlined version of ``pytest_terminal.py``: except (TypeError, ValueError): return str(v) -.. _`pytest_terminal.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_terminal.py +.. _`pytest_terminal.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_terminal.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/unittest.txt b/doc/test/plugin/unittest.txt index 21784ad2b..7629587de 100644 --- a/doc/test/plugin/unittest.txt +++ b/doc/test/plugin/unittest.txt @@ -155,7 +155,7 @@ For your convenience here is also an inlined version of ``pytest_unittest.py``: assert passed == 2 assert passed + skipped + failed == 2 -.. _`pytest_unittest.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_unittest.py +.. _`pytest_unittest.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_unittest.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html diff --git a/doc/test/plugin/xfail.txt b/doc/test/plugin/xfail.txt index 271f420dc..b558ca8ff 100644 --- a/doc/test/plugin/xfail.txt +++ b/doc/test/plugin/xfail.txt @@ -127,7 +127,7 @@ For your convenience here is also an inlined version of ``pytest_xfail.py``: ]) assert result.ret == 1 -.. _`pytest_xfail.py`: http://bitbucket.org/hpk42/py-trunk/raw/c28e76a64569475dda8b92c68f9c1c0902c5049e/py/test/plugin/pytest_xfail.py +.. _`pytest_xfail.py`: http://bitbucket.org/hpk42/py-trunk/raw/3d511a58acc10477ff4f766df4a9224cfc3546af/py/test/plugin/pytest_xfail.py .. _`extend`: ../extend.html .. _`plugins`: index.html .. _`contact`: ../../contact.html