diff options
| author | Viktor Kharkovets <3lnc.slam@gmail.com> | 2017-06-08 19:00:50 +0300 |
|---|---|---|
| committer | Viktor Kharkovets <3lnc.slam@gmail.com> | 2017-06-08 19:00:50 +0300 |
| commit | d248b4b4c2114f006478d6e35d77b25e693f81c1 (patch) | |
| tree | 294c40499b1a74176d7525f89d8792213d14b77f | |
| parent | cf1a1c00386ce42ff9c1d21744c1fab97853bc2c (diff) | |
| download | tox-git-d248b4b4c2114f006478d6e35d77b25e693f81c1.tar.gz | |
pytest #dropthedot
| -rw-r--r-- | CHANGELOG | 1 | ||||
| -rw-r--r-- | doc/config-v2.txt | 80 | ||||
| -rw-r--r-- | doc/config.txt | 2 | ||||
| -rw-r--r-- | doc/example/basic.txt | 2 | ||||
| -rw-r--r-- | doc/example/general.txt | 6 | ||||
| -rw-r--r-- | doc/example/jenkins.txt | 10 | ||||
| -rw-r--r-- | doc/example/pytest.txt | 24 | ||||
| -rw-r--r-- | doc/example/result.txt | 28 | ||||
| -rw-r--r-- | doc/index.txt | 4 | ||||
| -rw-r--r-- | tests/test_config.py | 64 | ||||
| -rw-r--r-- | tests/test_venv.py | 14 | ||||
| -rw-r--r-- | tests/test_z_cmdline.py | 10 | ||||
| -rw-r--r-- | tox.ini | 10 | ||||
| -rw-r--r-- | tox/_pytestplugin.py | 2 |
14 files changed, 127 insertions, 130 deletions
@@ -3,6 +3,7 @@ Not released yet - #474: Start using setuptools_scm for tag based versioning. - #506: With `-a`: do not show additional environments header if there are none +- #484: Renamed `py.test` to `pytest` through the project 2.7.0 ----- diff --git a/doc/config-v2.txt b/doc/config-v2.txt index daa19e13..288586ab 100644 --- a/doc/config-v2.txt +++ b/doc/config-v2.txt @@ -2,19 +2,19 @@ V2: new tox multi-dimensional, platform-specific configuration -------------------------------------------------------------------- .. note:: - + This is a draft document sketching a to-be-done implementation. It does not fully specify each change yet but should give a good - idea of where things are heading. For feedback, mail the + idea of where things are heading. For feedback, mail the testing-in-python mailing list or open a pull request on https://github.com/tox-dev/tox/blob/master/doc/config-v2.txt **Abstract**: Adding multi-dimensional configuration, platform-specification and multiple installers to tox.ini. - + **Target audience**: Developers using or wanting to use tox for testing their python projects. - + Issues with current tox (1.4) configuration ------------------------------------------------ @@ -22,17 +22,17 @@ Tox is used as a tool for creating and managing virtualenv environments and running tests in them. As of tox-1.4 there are some issues frequently coming up with its configuration language: -- there is no way to instruct tox to parametrize testenv specifications +- there is no way to instruct tox to parametrize testenv specifications other than to list all combinations by specifying a ``[testenv:...]`` - section for each combination. Examples of real life situations + section for each combination. Examples of real life situations arising from this: * https://github.com/tomchristie/django-rest-framework/blob/b001a146d73348af18cfc4c943d87f2f389349c9/tox.ini - + * https://bitbucket.org/tabo/django-treebeard/src/93b579395a9c/tox.ini - there is no way to have platform specific settings other than to - define specific testenvs and invoke tox with a platform-specific + define specific testenvs and invoke tox with a platform-specific testenv list. - there is no way to specify the platforms against which a project @@ -50,29 +50,29 @@ Goals, resolving those issues This document discusses a possible solution for each of these issues, namely these goals: - -- allow to more easily define and run dependency/interpreter variants + +- allow to more easily define and run dependency/interpreter variants with testenvs - allow platform-specific settings - allow to specify platforms against which tests should run - allow to run installer-variants (easy_install or pip, xxx) - try to mimick/re-use bash-style syntax to ease learning curve. - + Example: Generating and selecting variants ---------------------------------------------- - + Suppose you want to test your package against python2.6, python2.7 and on the -windows and linux platforms. Today you would have to +windows and linux platforms. Today you would have to write down 2*2 = 4 ``[testenv:*]`` sections and then instruct tox to run a specific list of environments on each platform. - + With tox-1.X you can directlys specify combinations:: - + # combination syntax gives 2 * 2 = 4 testenv names # envlist = {py26,py27}-{win,linux} - + [testenv] deps = pytest platform = @@ -81,7 +81,7 @@ With tox-1.X you can directlys specify combinations:: basepython = py26: python2.6 py27: python2.7 - commands = py.test + commands = pytest Let's go through this step by step:: @@ -103,7 +103,7 @@ Our ``[testenv]`` uses a new templating style for the ``platform`` definition:: These two conditional settings will lead to either ``windows`` or ``linux`` as the platform string. When the test environment is run, -its platform string needs to be contained in the string returned +its platform string needs to be contained in the string returned from ``platform.platform()``. Otherwise the environment will be skipped. The next configuration item in the ``testenv`` section deals with @@ -118,7 +118,7 @@ appears in the environment name. The last config item is simply the invocation of the test runner:: - commands = py.test + commands = pytest Nothing special here :) @@ -129,25 +129,25 @@ Nothing special here :) [tox] envlist = {py26,py27}-{win,linux} - + [testenv] deps = pytest - commands = py.test + commands = pytest - Voila, this multi-dimensional ``tox.ini`` configuration + Voila, this multi-dimensional ``tox.ini`` configuration defines 2*2=4 environments. - + The new "platform" setting -------------------------------------- A testenv can define a new ``platform`` setting. If its value -is not contained in the string obtained from calling +is not contained in the string obtained from calling ``sys.platform`` the environment will be skipped. Expanding the ``envlist`` setting ---------------------------------------------------------- - + The new ``envlist`` setting allows to use ``{}`` bash-style expressions. XXX explanation or pointer to bash-docs @@ -159,7 +159,7 @@ start with "NAME: ..." will be checked for being part in the environment name. If they are part of it, the remainder will be the new line. If they are not part of it, the whole line will be left out. Parts of an environment name are obtained by ``-``-splitting it. - + Variant specification with [variant:VARNAME] Showing all expanded sections @@ -172,12 +172,12 @@ you can ask tox to show their expansion with a new option:: Making sure your packages installs with easy_install ------------------------------------------------------ - + The new "installer" testenv setting allows to specify the tool for installation in a given test environment:: - + [testenv] - installer = + installer = easy: easy_install pip: pip @@ -199,7 +199,7 @@ tox comes with predefined settings for certain variants, namely: pythonNN or PyPy interpreter * ``{win32,linux,darwin}`` defines the according ``platform``. -You can use those in your “envlist” specification +You can use those in your “envlist” specification without the need to define them yourself. @@ -211,7 +211,7 @@ tox leverages bash-style syntax if you specify mintoxversion = 1.4: - $VARNAME or ${...} syntax instead of the older {} substitution. - XXX go through config.txt and see how it would need to be changed - + Transforming the examples: django-rest ------------------------------------------------ @@ -219,10 +219,10 @@ The original `django-rest-framework tox.ini <https://github.com/tomchristie/django-rest-framework/blob/b001a146d73348af18cfc4c943d87f2f389349c9/tox.ini>`_ file has 159 lines and a lot of repetition, the new one would +have 20 lines and almost no repetition:: - + [tox] envlist = {py25,py26,py27}-{django12,django13}{,-example} - + [testenv] deps= coverage==3.4 @@ -236,18 +236,18 @@ lines and almost no repetition:: example: httplib2==0.6.0 example: Markdown==2.0.3 - commands = + commands = !example: python setup.py test example: python examples/runtests.py - + Note that ``{,-example}`` in the envlist denotes two values, an empty one and a ``example`` one. The empty value means that there are no specific -settings and thus no need to define a variant name. +settings and thus no need to define a variant name. Transforming the examples: django-treebeard ------------------------------------------------ - + Another `tox.ini <https://bitbucket.org/tabo/django-treebeard/raw/93b579395a9c/tox.ini>`_ has 233 lines and runs tests against multiple Postgres and Mysql @@ -256,7 +256,7 @@ different command line options to the test script. With the new tox-1.X we not only can do the same with 32 non-repetive configuration lines but we also produce 36 specific testenvs with specific dependencies and test commands:: - + [tox] envlist = {py24,py25,py26,py27}-{django11,django12,django13}-{nodb,pg,mysql}, docs @@ -281,8 +281,8 @@ commands:: nodb: pysqlite pg: psycopg2 mysql: MySQL-python - - commands = + + commands = nodb: {envpython} runtests.py {posargs} pg: {envpython} runtests.py {posargs} \ --DATABASE_ENGINE=postgresql_psycopg2 \ diff --git a/doc/config.txt b/doc/config.txt index 2b2c9b45..390992f5 100644 --- a/doc/config.txt +++ b/doc/config.txt @@ -519,7 +519,7 @@ However, a better approach looks like this:: django15: Django>=1.5,<1.6 django16: Django>=1.6,<1.7 py26: unittest2 - commands = py.test + commands = pytest This uses two new facilities of tox-1.8: diff --git a/doc/example/basic.txt b/doc/example/basic.txt index 742944d9..3f0fa0f1 100644 --- a/doc/example/basic.txt +++ b/doc/example/basic.txt @@ -13,7 +13,7 @@ reside next to your ``setup.py`` file:: envlist = py26,py27 [testenv] deps=pytest # or 'nose' or ... - commands=py.test # or 'nosetests' or ... + commands=pytest # or 'nosetests' or ... To sdist-package, install and test your project, you can now type at the command prompt:: diff --git a/doc/example/general.txt b/doc/example/general.txt index 1a275494..eb14a44e 100644 --- a/doc/example/general.txt +++ b/doc/example/general.txt @@ -12,11 +12,11 @@ If you invoke ``tox`` like this:: the arguments after the ``--`` will be substituted everywhere where you specify ``{posargs}`` in your -test commands, for example using ``py.test``:: +test commands, for example using ``pytest``:: # in the testenv or testenv:NAME section of your tox.ini commands = - py.test {posargs} + pytest {posargs} or using ``nosetests``:: @@ -162,7 +162,7 @@ to deal with it in your commands section:: [testenv] commands = python setup.py develop - py.test + pytest Running ``setup.py develop`` is a common enough model that it has its own option:: diff --git a/doc/example/jenkins.txt b/doc/example/jenkins.txt index 32f185c1..260d14e8 100644 --- a/doc/example/jenkins.txt +++ b/doc/example/jenkins.txt @@ -32,11 +32,11 @@ using these steps: test results in the JUnit XML format. The last point requires that your test command creates JunitXML files, -for example with ``py.test`` it is done like this: +for example with ``pytest`` it is done like this: .. code-block:: ini - commands = py.test --junitxml=junit-{envname}.xml + commands = pytest --junitxml=junit-{envname}.xml @@ -80,7 +80,7 @@ If you are using a multi-configuration Jenkins job which collects JUnit Test results you will run into problems using the previous method of running the sphinx-build command because it will not generate JUnit results. To accomodate this issue one solution -is to have ``py.test`` wrap the sphinx-checks and create a +is to have ``pytest`` wrap the sphinx-checks and create a JUnit result file which wraps the result of calling sphinx-build. Here is an example: @@ -92,7 +92,7 @@ Here is an example: deps=sphinx py commands= - py.test --tb=line -v --junitxml=junit-{envname}.xml check_sphinx.py + pytest --tb=line -v --junitxml=junit-{envname}.xml check_sphinx.py 2. create a ``doc/check_sphinx.py`` file like this:: @@ -114,7 +114,7 @@ Here is an example: 3. run ``tox -e docs`` and then you may integrate this environment along with your other environments into Jenkins. -Note that ``py.test`` is only installed into the docs environment +Note that ``pytest`` is only installed into the docs environment and does not need to be in use or installed with any other environment. .. _`jenkins artifact example`: diff --git a/doc/example/pytest.txt b/doc/example/pytest.txt index 8876eb29..95bd8786 100644 --- a/doc/example/pytest.txt +++ b/doc/example/pytest.txt @@ -1,8 +1,8 @@ -py.test and tox +pytest and tox ================================= -It is easy to integrate `py.test`_ runs with tox. If you encounter +It is easy to integrate `pytest`_ runs with tox. If you encounter issues, please check if they are `listed as a known issue`_ and/or use the :doc:`support channels <../support>`. @@ -20,9 +20,9 @@ and the following ``tox.ini`` content:: envlist = py26,py31 [testenv] - deps=pytest # PYPI package providing py.test + deps=pytest # PYPI package providing pytest commands= - py.test \ + pytest \ {posargs} # substitute with tox' positional arguments you can now invoke ``tox`` in the directory where your ``tox.ini`` resides. @@ -47,12 +47,12 @@ and the following ``tox.ini`` content:: changedir=tests deps=pytest commands= - py.test \ - --basetemp={envtmpdir} \ # py.test tempdir setting + pytest \ + --basetemp={envtmpdir} \ # pytest tempdir setting {posargs} # substitute with tox' positional arguments you can invoke ``tox`` in the directory where your ``tox.ini`` resides. -Differently than in the previous example the ``py.test`` command +Differently than in the previous example the ``pytest`` command will be executed with a current working directory set to ``tests`` and the test run will use the per-virtualenv temporary directory. @@ -61,7 +61,7 @@ and the test run will use the per-virtualenv temporary directory. Using multiple CPUs for test runs ----------------------------------- -``py.test`` supports distributing tests to multiple processes and hosts +``pytest`` supports distributing tests to multiple processes and hosts through the `pytest-xdist`_ plugin. Here is an example configuration to make ``tox`` use this feature:: @@ -69,7 +69,7 @@ to make ``tox`` use this feature:: deps=pytest-xdist changedir=tests commands= - py.test \ + pytest \ --basetemp={envtmpdir} \ --confcutdir=.. \ -n 3 \ # use three sub processes @@ -81,12 +81,12 @@ Known Issues and limitations ----------------------------- **Too long filenames**. you may encounter "too long filenames" for temporarily -created files in your py.test run. Try to not use the "--basetemp" parameter. +created files in your pytest run. Try to not use the "--basetemp" parameter. -**installed-versus-checkout version**. ``py.test`` collects test +**installed-versus-checkout version**. ``pytest`` collects test modules on the filesystem and then tries to import them under their `fully qualified name`_. This means that if your test files are -importable from somewhere then your ``py.test`` invocation may end up +importable from somewhere then your ``pytest`` invocation may end up importing the package from the checkout directory rather than the installed package. diff --git a/doc/example/result.txt b/doc/example/result.txt index b3b95b48..21539982 100644 --- a/doc/example/result.txt +++ b/doc/example/result.txt @@ -14,31 +14,31 @@ This will create a json-formatted result file using this schema:: "testenvs": { "py27": { "python": { - "executable": "/home/hpk/p/tox/.tox/py27/bin/python", - "version": "2.7.3 (default, Aug 1 2012, 05:14:39) \n[GCC 4.6.3]", + "executable": "/home/hpk/p/tox/.tox/py27/bin/python", + "version": "2.7.3 (default, Aug 1 2012, 05:14:39) \n[GCC 4.6.3]", "version_info": [ 2, 7, 3, "final", 0 ] - }, + }, "test": [ { "output": "...", "command": [ - "/home/hpk/p/tox/.tox/py27/bin/py.test", - "--instafail", - "--junitxml=/home/hpk/p/tox/.tox/py27/log/junit-py27.xml", + "/home/hpk/p/tox/.tox/py27/bin/pytest", + "--instafail", + "--junitxml=/home/hpk/p/tox/.tox/py27/log/junit-py27.xml", "tests/test_config.py" - ], + ], "retcode": "0" } - ], + ], "setup": [] } - }, - "platform": "linux2", + }, + "platform": "linux2", "installpkg": { - "basename": "tox-1.6.0.dev1.zip", - "sha256": "b6982dde5789a167c4c35af0d34ef72176d0575955f5331ad04aee9f23af4326", + "basename": "tox-1.6.0.dev1.zip", + "sha256": "b6982dde5789a167c4c35af0d34ef72176d0575955f5331ad04aee9f23af4326", "md5": "27ead99fd7fa39ee7614cede6bf175a6" - }, - "toxversion": "1.6.0.dev1", + }, + "toxversion": "1.6.0.dev1", "reportversion": "1" } diff --git a/doc/index.txt b/doc/index.txt index 1fd50255..ae7924ae 100644 --- a/doc/index.txt +++ b/doc/index.txt @@ -35,7 +35,7 @@ right next to your ``setup.py`` file:: envlist = py26,py27 [testenv] deps=pytest # install pytest in the venvs - commands=py.test # or 'nosetests' or ... + commands=pytest # or 'nosetests' or ... You can also try generating a ``tox.ini`` file automatically, by running ``tox-quickstart`` and then answering a few simple questions. @@ -61,7 +61,7 @@ Current features - installs your ``setup.py`` based project into each virtual environment - - test-tool agnostic: runs py.test, nose or unittests in a uniform manner + - test-tool agnostic: runs pytest, nose or unittests in a uniform manner * :doc:`(new in 2.0) plugin system <plugins>` to modify tox execution with simple hooks. diff --git a/tests/test_config.py b/tests/test_config.py index 4eac45e6..8b663d3c 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -355,7 +355,7 @@ class TestIniParser: """) reader = SectionReader("mydefault", config._cfg, fallbacksections=['mydefault']) assert reader is not None - with py.test.raises(tox.exception.ConfigError): + with pytest.raises(tox.exception.ConfigError): reader.getstring("key2") def test_getstring_fallback_sections(self, tmpdir, newconfig): @@ -429,7 +429,7 @@ class TestIniParser: reader = SectionReader("section", config._cfg) x = reader.getstring("key1") assert x == "hello" - with py.test.raises(tox.exception.ConfigError): + with pytest.raises(tox.exception.ConfigError): reader.getstring("key2") def test_getstring_environment_substitution_with_default(self, monkeypatch, newconfig): @@ -476,7 +476,7 @@ class TestIniParser: """) reader = SectionReader("section", config._cfg) reader.addsubstitutions(item1="with space", item2="grr") - # py.test.raises(tox.exception.ConfigError, + # pytest.raises(tox.exception.ConfigError, # "reader.getargvlist('key1')") assert reader.getargvlist('key1') == [] x = reader.getargvlist("key2") @@ -486,12 +486,12 @@ class TestIniParser: def test_argvlist_windows_escaping(self, tmpdir, newconfig): config = newconfig(""" [section] - comm = py.test {posargs} + comm = pytest {posargs} """) reader = SectionReader("section", config._cfg) reader.addsubstitutions([r"hello\this"]) argv = reader.getargv("comm") - assert argv == ["py.test", "hello\\this"] + assert argv == ["pytest", "hello\\this"] def test_argvlist_multiline(self, tmpdir, newconfig): config = newconfig(""" @@ -502,7 +502,7 @@ class TestIniParser: """) reader = SectionReader("section", config._cfg) reader.addsubstitutions(item1="with space", item2="grr") - # py.test.raises(tox.exception.ConfigError, + # pytest.raises(tox.exception.ConfigError, # "reader.getargvlist('key1')") assert reader.getargvlist('key1') == [] x = reader.getargvlist("key2") @@ -550,7 +550,7 @@ class TestIniParser: reader = SectionReader("section", config._cfg) posargs = ['hello', 'world'] reader.addsubstitutions(posargs, item2="value2") - # py.test.raises(tox.exception.ConfigError, + # pytest.raises(tox.exception.ConfigError, # "reader.getargvlist('key1')") assert reader.getargvlist('key1') == [] argvlist = reader.getargvlist("key2") @@ -559,7 +559,7 @@ class TestIniParser: reader = SectionReader("section", config._cfg) reader.addsubstitutions([], item2="value2") - # py.test.raises(tox.exception.ConfigError, + # pytest.raises(tox.exception.ConfigError, # "reader.getargvlist('key1')") assert reader.getargvlist('key1') == [] argvlist = reader.getargvlist("key2") @@ -627,7 +627,7 @@ class TestIniParser: def test_substitution_with_multiple_words(self, newconfig): inisource = """ [section] - key = py.test -n5 --junitxml={envlogdir}/junit-{envname}.xml [] + key = pytest -n5 --junitxml={envlogdir}/junit-{envname}.xml [] """ config = newconfig(inisource) reader = SectionReader("section", config._cfg) @@ -635,7 +635,7 @@ class TestIniParser: reader.addsubstitutions(posargs, envlogdir='ENV_LOG_DIR', envname='ENV_NAME') expected = [ - 'py.test', '-n5', '--junitxml=ENV_LOG_DIR/junit-ENV_NAME.xml', 'hello', 'world' + 'pytest', '-n5', '--junitxml=ENV_LOG_DIR/junit-ENV_NAME.xml', 'hello', 'world' ] assert reader.getargvlist('key')[0] == expected @@ -672,8 +672,8 @@ class TestIniParser: assert reader.getbool("key1a") is True assert reader.getbool("key2") is False assert reader.getbool("key2a") is False - py.test.raises(KeyError, 'reader.getbool("key3")') - py.test.raises(tox.exception.ConfigError, 'reader.getbool("key5")') + pytest.raises(KeyError, 'reader.getbool("key3")') + pytest.raises(tox.exception.ConfigError, 'reader.getbool("key5")') class TestIniParserPrefix: @@ -986,7 +986,7 @@ class TestConfigTestEnv: 'some_install', '{packages}'] def test_install_command_must_contain_packages(self, newconfig): - py.test.raises(tox.exception.ConfigError, newconfig, """ + pytest.raises(tox.exception.ConfigError, newconfig, """ [testenv] install_command=pip install """) @@ -1032,7 +1032,7 @@ class TestConfigTestEnv: assert "py27" in config.envconfigs def test_substitution_error(tmpdir, newconfig): - py.test.raises(tox.exception.ConfigError, newconfig, """ + pytest.raises(tox.exception.ConfigError, newconfig, """ [testenv:py27] basepython={xyz} """) @@ -1288,7 +1288,7 @@ class TestConfigTestEnv: deps= {[testing:pytest]deps} """ - py.test.raises(ValueError, newconfig, [], inisource) + pytest.raises(ValueError, newconfig, [], inisource) def test_single_value_from_other_secton(self, newconfig, tmpdir): inisource = """ @@ -1491,7 +1491,7 @@ class TestGlobalOptions: [testenv:py27] basepython=python2.7 """ - # py.test.raises(tox.exception.ConfigError, + # pytest.raises(tox.exception.ConfigError, # "newconfig(['-exyz'], inisource)") config = newconfig([], inisource) assert config.envlist == ["py26"] @@ -1566,7 +1566,7 @@ class TestGlobalOptions: [tox] minversion = 10.0 """ - with py.test.raises(tox.exception.MinVersionError): + with pytest.raises(tox.exception.MinVersionError): newconfig([], inisource) def test_skip_missing_interpreters_true(self, tmpdir, newconfig, monkeypatch): @@ -1980,8 +1980,8 @@ class TestCmdInvocation: 'tox.ini': ''' [tox] envlist=py26,py27,py33,pypy,docs - description= py27: run py.test on Python 2.7 - py33: run py.test on Python 3.6 + description= py27: run pytest on Python 2.7 + py33: run pytest on Python 3.6 pypy: publish to pypy docs: document stuff notincluded: random extra @@ -2008,9 +2008,9 @@ class TestCmdInvocation: [tox] envlist=py26,py27,py33,pypy,docs [testenv] - description= py26: run py.test on Python 2.6 - py27: run py.test on Python 2.7 - py33: run py.test on Python 3.3 + description= py26: run pytest on Python 2.6 + py27: run pytest on Python 2.7 + py33: run pytest on Python 3.3 pypy: publish to pypy docs: document stuff notincluded: random extra @@ -2026,9 +2026,9 @@ class TestCmdInvocation: result = cmd.run("tox", "-lv") result.stdout.fnmatch_lines(""" default environments: - py26 -> run py.test on Python 2.6 - py27 -> run py.test on Python 2.7 - py33 -> run py.test on Python 3.3 + py26 -> run pytest on Python 2.6 + py27 -> run pytest on Python 2.7 + py33 -> run pytest on Python 3.3 pypy -> publish to pypy docs -> let me overwrite that """) @@ -2062,12 +2062,12 @@ class TestCmdInvocation: [tox] envlist={py27,py36}-{windows,linux} [testenv] - description= py27: run py.test on Python 2.7 - py36: run py.test on Python 3.6 + description= py27: run pytest on Python 2.7 + py36: run pytest on Python 3.6 windows: on Windows platform linux: on Linux platform docs: generate documentation - commands=py.test {posargs} + commands=pytest {posargs} [testenv:docs] changedir = docs @@ -2076,10 +2076,10 @@ class TestCmdInvocation: result = cmd.run("tox", "-av") result.stdout.fnmatch_lines(""" default environments: - py27-windows -> run py.test on Python 2.7 on Windows platform - py27-linux -> run py.test on Python 2.7 on Linux platform - py36-windows -> run py.test on Python 3.6 on Windows platform - py36-linux -> run py.test on Python 3.6 on Linux platform + py27-windows -> run pytest on Python 2.7 on Windows platform + py27-linux -> run pytest on Python 2.7 on Linux platform + py36-windows -> run pytest on Python 3.6 on Windows platform + py36-linux -> run pytest on Python 3.6 on Linux platform additional environments: docs -> generate documentation diff --git a/tests/test_venv.py b/tests/test_venv.py index 246581b6..3cd544f4 100644 --- a/tests/test_venv.py +++ b/tests/test_venv.py @@ -34,13 +34,11 @@ def test_getsupportedinterpreter(monkeypatch, newconfig, mocksession): assert py.path.local(interp).realpath() == py.path.local(sys.executable).realpath() monkeypatch.setattr(sys, 'platform', "win32") monkeypatch.setattr(venv.envconfig, 'basepython', 'jython') - py.test.raises(tox.exception.UnsupportedInterpreter, - venv.getsupportedinterpreter) + pytest.raises(tox.exception.UnsupportedInterpreter, venv.getsupportedinterpreter) monkeypatch.undo() monkeypatch.setattr(venv.envconfig, "envname", "py1") monkeypatch.setattr(venv.envconfig, 'basepython', 'notexistingpython') - py.test.raises(tox.exception.InterpreterNotFound, - venv.getsupportedinterpreter) + pytest.raises(tox.exception.InterpreterNotFound, venv.getsupportedinterpreter) monkeypatch.undo() # check that we properly report when no version_info is present info = NoInterpreterInfo(name=venv.name) @@ -345,7 +343,7 @@ def test_install_command_not_installed(newmocksession, monkeypatch): mocksession = newmocksession(['--recreate'], """ [testenv] commands= - py.test + pytest """) venv = mocksession.getenv('python') venv.test() @@ -356,10 +354,10 @@ def test_install_command_not_installed(newmocksession, monkeypatch): def test_install_command_whitelisted(newmocksession, monkeypatch): mocksession = newmocksession(['--recreate'], """ [testenv] - whitelist_externals = py.test + whitelist_externals = pytest xy* commands= - py.test + pytest xyz """) venv = mocksession.getenv('python') @@ -556,7 +554,7 @@ class TestVenvTest: monkeypatch.setenv("PIP_RESPECT_VIRTUALENV", "1") monkeypatch.setenv("PIP_REQUIRE_VIRTUALENV", "1") monkeypatch.setenv("__PYVENV_LAUNCHER__", "1") - py.test.raises(ZeroDivisionError, "venv.run_install_command(['qwe'], action=action)") + pytest.raises(ZeroDivisionError, "venv.run_install_command(['qwe'], action=action)") assert 'PIP_RESPECT_VIRTUALENV' not in os.environ assert 'PIP_REQUIRE_VIRTUALENV' not in os.environ assert '__PYVENV_LAUNCHER__' not in os.environ diff --git a/tests/test_z_cmdline.py b/tests/test_z_cmdline.py index b9783d53..93d2e366 100644 --- a/tests/test_z_cmdline.py +++ b/tests/test_z_cmdline.py @@ -42,11 +42,9 @@ def test_report_protocol(newconfig): def test__resolve_pkg(tmpdir, mocksession): distshare = tmpdir.join("distshare") spec = distshare.join("pkg123-*") - py.test.raises(tox.exception.MissingDirectory, - 'mocksession._resolve_pkg(spec)') + pytest.raises(tox.exception.MissingDirectory, 'mocksession._resolve_pkg(spec)') distshare.ensure(dir=1) - py.test.raises(tox.exception.MissingDependency, - 'mocksession._resolve_pkg(spec)') + pytest.raises(tox.exception.MissingDependency, 'mocksession._resolve_pkg(spec)') distshare.ensure("pkg123-1.3.5.zip") p = distshare.ensure("pkg123-1.4.5.zip") @@ -490,7 +488,7 @@ class TestToxRun: 'tox.ini': ''' [testenv] changedir=tests - commands= py.test --basetemp={envtmpdir} \ + commands= pytest --basetemp={envtmpdir} \ --junitxml=junit-{envname}.xml deps=pytest ''' @@ -590,7 +588,7 @@ def test_test_usedevelop(cmd, initproj, src_root): usedevelop=True changedir=tests commands= - py.test --basetemp={envtmpdir} --junitxml=junit-{envname}.xml [] + pytest --basetemp={envtmpdir} --junitxml=junit-{envname}.xml [] deps=pytest ''' }) @@ -5,7 +5,7 @@ envlist=py27,py26,py34,py33,py35,py36,pypy,flakes,py26-bare commands=echo {posargs} [testenv] -commands= py.test --timeout=180 {posargs:tests} +commands= pytest --timeout=180 {posargs:tests} deps=pytest>=3.0.0 pytest-timeout @@ -27,15 +27,15 @@ changedir=doc deps=sphinx {[testenv]deps} commands= - py.test -v check_sphinx.py {posargs} + pytest -v check_sphinx.py {posargs} [testenv:flakes] deps = pytest-flakes>=0.2 pytest-pep8 commands = - py.test --flakes -m flakes tox tests - py.test --pep8 -m pep8 tox tests + pytest --flakes -m flakes tox tests + pytest --pep8 -m pep8 tox tests [testenv:dev] # required to make looponfail reload on every source code change @@ -43,7 +43,7 @@ usedevelop = True deps = pytest-xdist>=1.11 -commands = {posargs:py.test -s -x -f -v} +commands = {posargs:pytest -s -x -f -v} [pytest] rsyncdirs = tests tox diff --git a/tox/_pytestplugin.py b/tox/_pytestplugin.py index 64a5f3e8..124fbb9d 100644 --- a/tox/_pytestplugin.py +++ b/tox/_pytestplugin.py @@ -189,7 +189,7 @@ class Cmd: def popen(self, argv, stdout, stderr, **kw): if not hasattr(py.std, 'subprocess'): - py.test.skip("no subprocess module") + pytest.skip("no subprocess module") env = os.environ.copy() env['PYTHONPATH'] = ":".join(filter(None, [ str(os.getcwd()), env.get('PYTHONPATH', '')])) |
