Skip to content

Commit

Permalink
Introduce pytest command as recommended entry point
Browse files Browse the repository at this point in the history
Fixes #1629
  • Loading branch information
davehunt committed Jun 21, 2016
1 parent 54872e9 commit ef9dd14
Show file tree
Hide file tree
Showing 55 changed files with 273 additions and 275 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Here's a quick checklist in what to include:

- [ ] Include a detailed description of the bug or suggestion
- [ ] `pip list` of the virtual environment you are using
- [ ] py.test and operating system versions
- [ ] pytest and operating system versions
- [ ] Minimal example if possible
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ An example of a simple test:
To execute it::

$ py.test
$ pytest
======= test session starts ========
platform linux -- Python 3.4.3, pytest-2.8.5, py-1.4.31, pluggy-0.3.1
collected 1 items
Expand All @@ -51,7 +51,7 @@ To execute it::
test_sample.py:5: AssertionError
======= 1 failed in 0.12 seconds ========

Due to ``py.test``'s detailed assertion introspection, only plain ``assert`` statements are used. See `getting-started <http://pytest.org/latest/getting-started.html#our-first-test-run>`_ for more examples.
Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` statements are used. See `getting-started <http://pytest.org/latest/getting-started.html#our-first-test-run>`_ for more examples.


Features
Expand Down
2 changes: 1 addition & 1 deletion _pytest/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def _readline_workaround():
Pdb uses readline support where available--when not running from the Python
prompt, the readline module is not imported until running the pdb REPL. If
running py.test with the --pdb option this means the readline module is not
running pytest with the --pdb option this means the readline module is not
imported until after I/O capture has been started.
This is a problem for pyreadline, which is often used to implement readline
Expand Down
2 changes: 1 addition & 1 deletion _pytest/genscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def pytest_namespace():

def freeze_includes():
"""
Returns a list of module names used by py.test that should be
Returns a list of module names used by pytest that should be
included by cx_freeze.
"""
result = list(_iter_all_modules(py))
Expand Down
4 changes: 2 additions & 2 deletions _pytest/helpconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def showhelp(config):
tw.line()
tw.line()

tw.line("to see available markers type: py.test --markers")
tw.line("to see available fixtures type: py.test --fixtures")
tw.line("to see available markers type: pytest --markers")
tw.line("to see available fixtures type: pytest --fixtures")
tw.line("(shown according to specified file_or_dir or current dir "
"if not specified)")

Expand Down
2 changes: 1 addition & 1 deletion _pytest/hookspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def pytest_addoption(parser):
.. note::
This function should be implemented only in plugins or ``conftest.py``
files situated at the tests root directory due to how py.test
files situated at the tests root directory due to how pytest
:ref:`discovers plugins during startup <pluginorder>`.
:arg parser: To add command line options, call
Expand Down
30 changes: 15 additions & 15 deletions _pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,10 @@ def assert_outcomes(self, passed=0, skipped=0, failed=0):


class Testdir:
"""Temporary test directory with tools to test/run py.test itself.
"""Temporary test directory with tools to test/run pytest itself.
This is based on the ``tmpdir`` fixture but provides a number of
methods which aid with testing py.test itself. Unless
methods which aid with testing pytest itself. Unless
:py:meth:`chdir` is used all methods will use :py:attr:`tmpdir` as
current working directory.
Expand Down Expand Up @@ -588,7 +588,7 @@ def getpathnode(self, path):
"""Return the collection node of a file.
This is like :py:meth:`getnode` but uses
:py:meth:`parseconfigure` to create the (configured) py.test
:py:meth:`parseconfigure` to create the (configured) pytest
Config instance.
:param path: A :py:class:`py.path.local` instance of the file.
Expand Down Expand Up @@ -656,7 +656,7 @@ def inline_genitems(self, *args):
:py:class:`HookRecorder` instance.
This runs the :py:func:`pytest.main` function to run all of
py.test inside the test process itself like
pytest inside the test process itself like
:py:meth:`inline_run`. However the return value is a tuple of
the collection items and a :py:class:`HookRecorder` instance.
Expand All @@ -669,7 +669,7 @@ def inline_run(self, *args, **kwargs):
"""Run ``pytest.main()`` in-process, returning a HookRecorder.
This runs the :py:func:`pytest.main` function to run all of
py.test inside the test process itself. This means it can
pytest inside the test process itself. This means it can
return a :py:class:`HookRecorder` instance which gives more
detailed results from then run then can be done by matching
stdout/stderr from :py:meth:`runpytest`.
Expand Down Expand Up @@ -755,9 +755,9 @@ def _ensure_basetemp(self, args):
return args

def parseconfig(self, *args):
"""Return a new py.test Config instance from given commandline args.
"""Return a new pytest Config instance from given commandline args.
This invokes the py.test bootstrapping code in _pytest.config
This invokes the pytest bootstrapping code in _pytest.config
to create a new :py:class:`_pytest.core.PluginManager` and
call the pytest_cmdline_parse hook to create new
:py:class:`_pytest.config.Config` instance.
Expand All @@ -777,7 +777,7 @@ def parseconfig(self, *args):
return config

def parseconfigure(self, *args):
"""Return a new py.test configured Config instance.
"""Return a new pytest configured Config instance.
This returns a new :py:class:`_pytest.config.Config` instance
like :py:meth:`parseconfig`, but also calls the
Expand All @@ -792,7 +792,7 @@ def parseconfigure(self, *args):
def getitem(self, source, funcname="test_func"):
"""Return the test item for a test function.
This writes the source to a python file and runs py.test's
This writes the source to a python file and runs pytest's
collection on the resulting module, returning the test item
for the requested function name.
Expand All @@ -812,7 +812,7 @@ def getitem(self, source, funcname="test_func"):
def getitems(self, source):
"""Return all test items collected from the module.
This writes the source to a python file and runs py.test's
This writes the source to a python file and runs pytest's
collection on the resulting module, returning all test items
contained within.
Expand All @@ -824,7 +824,7 @@ def getmodulecol(self, source, configargs=(), withinit=False):
"""Return the module collection node for ``source``.
This writes ``source`` to a file using :py:meth:`makepyfile`
and then runs the py.test collection on it, returning the
and then runs the pytest collection on it, returning the
collection node for the test module.
:param source: The source code of the module to collect.
Expand Down Expand Up @@ -924,7 +924,7 @@ def _dump_lines(self, lines, fp):

def _getpytestargs(self):
# we cannot use "(sys.executable,script)"
# because on windows the script is e.g. a py.test.exe
# because on windows the script is e.g. a pytest.exe
return (sys.executable, _pytest_fullpath,) # noqa

def runpython(self, script):
Expand All @@ -939,7 +939,7 @@ def runpython_c(self, command):
return self.run(sys.executable, "-c", command)

def runpytest_subprocess(self, *args, **kwargs):
"""Run py.test as a subprocess with given arguments.
"""Run pytest as a subprocess with given arguments.
Any plugins added to the :py:attr:`plugins` list will added
using the ``-p`` command line option. Addtionally
Expand Down Expand Up @@ -967,9 +967,9 @@ def runpytest_subprocess(self, *args, **kwargs):
return self.run(*args)

def spawn_pytest(self, string, expect_timeout=10.0):
"""Run py.test using pexpect.
"""Run pytest using pexpect.
This makes sure to use the right py.test and sets up the
This makes sure to use the right pytest and sets up the
temporary directory locations.
The pexpect child is returned.
Expand Down
2 changes: 1 addition & 1 deletion _pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -2173,7 +2173,7 @@ def formatrepr(self):
available.append(name)
msg = "fixture %r not found" % (self.argname,)
msg += "\n available fixtures: %s" %(", ".join(available),)
msg += "\n use 'py.test --fixtures [testpath]' for help on them."
msg += "\n use 'pytest --fixtures [testpath]' for help on them."

return FixtureLookupErrorRepr(fspath, lineno, tblines, msg, self.argname)

Expand Down
2 changes: 1 addition & 1 deletion _pytest/standalonetemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
# If you're wondering how this is created: you can create it yourself if you
# have a complete pytest installation by using this command on the command-
# line: ``py.test --genscript=runtests.py``.
# line: ``pytest --genscript=runtests.py``.

sources = """
@SOURCES@"""
Expand Down
6 changes: 3 additions & 3 deletions doc/en/assert.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ following::
to assert that your function returns a certain value. If this assertion fails
you will see the return value of the function call::

$ py.test test_assert1.py
$ pytest test_assert1.py
======= test session starts ========
platform linux -- Python 3.5.1, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: $REGENDOC_TMPDIR, inifile:
Expand Down Expand Up @@ -168,7 +168,7 @@ when it encounters comparisons. For example::

if you run this module::

$ py.test test_assert2.py
$ pytest test_assert2.py
======= test session starts ========
platform linux -- Python 3.5.1, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: $REGENDOC_TMPDIR, inifile:
Expand Down Expand Up @@ -237,7 +237,7 @@ now, given this test module::
you can run the test module and get the custom output defined in
the conftest file::

$ py.test -q test_foocompare.py
$ pytest -q test_foocompare.py
F
======= FAILURES ========
_______ test_compare ________
Expand Down
4 changes: 2 additions & 2 deletions doc/en/bash-completion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ For global activation of all argcomplete enabled python applications run::

For permanent (but not global) ``pytest`` activation, use::

register-python-argcomplete py.test >> ~/.bashrc
register-python-argcomplete pytest >> ~/.bashrc

For one-time activation of argcomplete for ``pytest`` only, use::

eval "$(register-python-argcomplete py.test)"
eval "$(register-python-argcomplete pytest)"



2 changes: 1 addition & 1 deletion doc/en/builtin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Builtin fixtures/function arguments
You can ask for available builtin or project-custom
:ref:`fixtures <fixtures>` by typing::

$ py.test -q --fixtures
$ pytest -q --fixtures
cache
Return a cache object that can persist state between testing sessions.
Expand Down
20 changes: 10 additions & 10 deletions doc/en/cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Usage
---------

The plugin provides two command line options to rerun failures from the
last ``py.test`` invocation:
last ``pytest`` invocation:

* ``--lf``, ``--last-failed`` - to only re-run the failures.
* ``--ff``, ``--failed-first`` - to run the failures first and then the rest of
Expand All @@ -25,7 +25,7 @@ For cleanup (usually not needed), a ``--cache-clear`` option allows to remove
all cross-session cache contents ahead of a test run.

Other plugins may access the `config.cache`_ object to set/get
**json encodable** values between ``py.test`` invocations.
**json encodable** values between ``pytest`` invocations.

.. note::

Expand All @@ -49,7 +49,7 @@ First, let's create 50 test invocation of which only 2 fail::

If you run this for the first time you will see two failures::

$ py.test -q
$ pytest -q
.................F.......F........................
======= FAILURES ========
_______ test_num[17] ________
Expand Down Expand Up @@ -78,7 +78,7 @@ If you run this for the first time you will see two failures::

If you then run it with ``--lf``::

$ py.test --lf
$ pytest --lf
======= test session starts ========
platform linux -- Python 3.5.1, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
run-last-failure: rerun last 2 failures
Expand Down Expand Up @@ -119,7 +119,7 @@ Now, if you run with the ``--ff`` option, all tests will be run but the first
previous failures will be executed first (as can be seen from the series
of ``FF`` and dots)::

$ py.test --ff
$ pytest --ff
======= test session starts ========
platform linux -- Python 3.5.1, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
run-last-failure: rerun last 2 failures first
Expand Down Expand Up @@ -163,7 +163,7 @@ The new config.cache object
Plugins or conftest.py support code can get a cached value using the
pytest ``config`` object. Here is a basic example plugin which
implements a :ref:`fixture` which re-uses previously created state
across py.test invocations::
across pytest invocations::

# content of test_caching.py
import pytest
Expand All @@ -184,7 +184,7 @@ across py.test invocations::
If you run this command once, it will take a while because
of the sleep::

$ py.test -q
$ pytest -q
F
======= FAILURES ========
_______ test_function ________
Expand All @@ -201,7 +201,7 @@ of the sleep::
If you run it a second time the value will be retrieved from
the cache and this will be quick::

$ py.test -q
$ pytest -q
F
======= FAILURES ========
_______ test_function ________
Expand All @@ -224,7 +224,7 @@ Inspecting Cache content
You can always peek at the content of the cache using the
``--cache-clear`` command line option::

$ py.test --cache-clear
$ pytest --cache-clear
======= test session starts ========
platform linux -- Python 3.5.1, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: $REGENDOC_TMPDIR, inifile:
Expand All @@ -250,7 +250,7 @@ Clearing Cache content
You can instruct pytest to clear all cache files and values
by adding the ``--cache-clear`` option like this::

py.test --cache-clear
pytest --cache-clear

This is recommended for invocations from Continous Integration
servers where isolation and correctness is more important
Expand Down
8 changes: 4 additions & 4 deletions doc/en/capture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ There are two ways in which ``pytest`` can perform capturing:

You can influence output capturing mechanisms from the command line::

py.test -s # disable all capturing
py.test --capture=sys # replace sys.stdout/stderr with in-mem files
py.test --capture=fd # also point filedescriptors 1 and 2 to temp file
pytest -s # disable all capturing
pytest --capture=sys # replace sys.stdout/stderr with in-mem files
pytest --capture=fd # also point filedescriptors 1 and 2 to temp file

.. _printdebugging:

Expand All @@ -62,7 +62,7 @@ is that you can use print statements for debugging::
and running this module will show you precisely the output
of the failing function and hide the other one::

$ py.test
$ pytest
======= test session starts ========
platform linux -- Python 3.5.1, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: $REGENDOC_TMPDIR, inifile:
Expand Down
10 changes: 5 additions & 5 deletions doc/en/customize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Command line options and configuration file settings
You can get help on command line options and values in INI-style
configurations files by using the general help option::

py.test -h # prints options _and_ config file settings
pytest -h # prints options _and_ config file settings

This will display command line and configuration file settings
which were registered by installed plugins.
Expand Down Expand Up @@ -62,7 +62,7 @@ per-testrun information.

Example::

py.test path/to/testdir path/other/
pytest path/to/testdir path/other/

will determine the common ancestor as ``path`` and then
check for ini-files as follows::
Expand Down Expand Up @@ -126,9 +126,9 @@ Builtin configuration file options
[pytest]
addopts = --maxfail=2 -rf # exit after 2 failures, report fail info
issuing ``py.test test_hello.py`` actually means::
issuing ``pytest test_hello.py`` actually means::

py.test --maxfail=2 -rf test_hello.py
pytest --maxfail=2 -rf test_hello.py

Default is to add no options.

Expand Down Expand Up @@ -218,7 +218,7 @@ Builtin configuration file options
.. confval:: doctest_optionflags

One or more doctest flag names from the standard ``doctest`` module.
:doc:`See how py.test handles doctests <doctest>`.
:doc:`See how pytest handles doctests <doctest>`.

.. confval:: confcutdir

Expand Down
Loading

0 comments on commit ef9dd14

Please sign in to comment.