Skip to content

Commit

Permalink
Merge branch 'master' into testpaths-for-managepy-check
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Oct 10, 2017
2 parents a835c2e + 781daae commit 5aa9790
Show file tree
Hide file tree
Showing 20 changed files with 157 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[run]
parallel = true
source = pytest_django
source = pytest_django,pytest_django_test,tests
branch = true
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ _build
/.coverage.*
/.coverage
/htmlcov/
/bin/
/include/
/lib/
/src/
/share/
.cache
.Python
.eggs
Expand Down
72 changes: 42 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,55 @@ language: python
matrix:
fast_finish: true
include:

- python: 3.6
env: TOXENV=py36-pytest30-djangomaster-postgres
env: TOXENV=py36-pytest3-djangomaster-postgres
- python: 3.6
env: TOXENV=py36-pytest30-django1.11-postgres
env: TOXENV=py36-pytest3-django1.11-postgres
- python: 3.6
env: TOXENV=py36-pytest30-django1.10-postgres
env: TOXENV=py36-pytest3-django1.10-postgres
- python: 3.6
env: TOXENV=py36-pytest30-django1.9-postgres
env: TOXENV=py36-pytest3-django1.9-postgres
- python: 3.6
env: TOXENV=py36-pytest30-django1.8-postgres
env: TOXENV=py36-pytest3-django1.8-postgres
- python: 3.6
env: TOXENV=py36-checkqa

- python: 3.5
env: TOXENV=py35-pytest30-django1.11-postgres
env: TOXENV=py35-pytest3-django1.11-postgres

- python: 3.4
env: TOXENV=py34-pytest30-django1.11-postgres
env: TOXENV=py34-pytest3-django1.11-postgres

- python: 3.3
env: TOXENV=py34-pytest30-django1.8-postgres
env: TOXENV=py34-pytest3-django1.8-postgres

- python: 2.7
env: TOXENV=py27-pytest30-django1.11-mysql_innodb
env: TOXENV=py27-pytest3-django1.11-mysql_innodb
- python: 2.7
env: TOXENV=py27-pytest30-django1.11-mysql_myisam
env: TOXENV=py27-pytest3-django1.11-mysql_myisam
- python: 2.7
env: TOXENV=py27-pytest30-django1.11-postgres
env: TOXENV=py27-pytest3-django1.11-postgres
- python: 2.7
env: TOXENV=py27-pytest30-django1.10-postgres
env: TOXENV=py27-pytest3-django1.10-postgres
- python: 2.7
env: TOXENV=py27-pytest30-django1.9-postgres
env: TOXENV=py27-pytest3-django1.9-postgres
- python: 2.7
env: TOXENV=py27-pytest30-django1.8-postgres
env: TOXENV=py27-pytest3-django1.8-postgres
- python: 2.7
env: TOXENV=py27-pytest30-django1.7-postgres
env: TOXENV=py27-pytest3-django1.7-postgres
- python: 2.7
env: TOXENV=py27-checkqa

- python: pypy
env: TOXENV=pypy-pytest30-django1.11-sqlite_file
env: TOXENV=pypy-pytest3-django1.11-sqlite_file

- python: pypy3
env: TOXENV=pypy3-pytest30-django1.8-sqlite
env: TOXENV=pypy3-pytest3-django1.8-sqlite
- python: pypy3
env: TOXENV=pypy3-pytest30-django1.10-sqlite_file
env: TOXENV=pypy3-pytest3-django1.10-sqlite_file

allow_failures:
- env: TOXENV=py36-pytest30-djangomaster-postgres

# Temporary.
# https://github.com/pytest-dev/pytest-django/pull/445
# https://github.com/pytest-dev/pytest-django/issues/448
- env: TOXENV=pypy3-pytest30-django1.8-sqlite
- env: TOXENV=pypy3-pytest30-django1.10-sqlite_file
- env: TOXENV=py36-pytest3-djangomaster-postgres

cache:
directories:
Expand All @@ -76,12 +69,31 @@ install:
- printf '\necho "Using pip-wrapper.." >&2\ntravis_retry pip "$@"' >> bin/travis_retry_pip
- chmod +x bin/travis_retry_pip
- sed -i.bak 's/^\[testenv\]/\0\ninstall_command = travis_retry_pip install {opts} {packages}/' tox.ini
- diff tox.ini tox.ini.bak && return 1 || true
- sed -i.bak 's/whitelist_externals =/\0\n travis_retry_pip/' tox.ini
- diff tox.ini tox.ini.bak && return 1 || true
- if diff tox.ini tox.ini.bak; then exit 1; fi
- printf '\nwhitelist_externals = travis_retry_pip' >> tox.ini

- pip install tox==2.3.1
- pip install tox==2.7.0
- |
if [[ "${TOXENV%-checkqa}" == "$TOXENV" ]]; then
export PYTEST_ADDOPTS='--cov=pytest_django --cov=tests --cov=pytest_django_test --cov-report=term-missing:skip-covered'
export _PYTESTDJANGO_TOX_EXTRA_DEPS=pytest-cov
fi
script:
- tox
- "find ${TRAVIS_BUILD_DIR}/.tox -name 'log' -o -name '__pycache__' -type d | xargs -I {} rm -rf {}"

after_success:
- |
set -ex
if [[ "${TOXENV%-checkqa}" == "$TOXENV" ]]; then
pip install codecov
coverage combine
coverage xml
coverage report -m --skip-covered
codecov_flags=${TOXENV//./}
codecov_flags=${codecov_flags//-/ }
codecov --required -X search gcov pycov -f coverage.xml --flags $codecov_flags
fi
set +x
26 changes: 14 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
.PHONY: docs test clean isort

VENV:=build/venv

export DJANGO_SETTINGS_MODULE?=pytest_django_test.settings_sqlite_file

testenv: bin/py.test
testenv: $(VENV)/bin/pytest

test: bin/py.test
bin/pip install -e .
bin/py.test
test: $(VENV)/bin/pytest
$(VENV)/bin/pip install -e .
$(VENV)/bin/py.test

bin/python bin/pip:
virtualenv .
$(VENV)/bin/python $(VENV)/bin/pip:
virtualenv $(VENV)

bin/py.test: bin/python requirements.txt
bin/pip install -Ur requirements.txt
$(VENV)/bin/pytest: $(VENV)/bin/python requirements.txt
$(VENV)/bin/pip install -Ur requirements.txt
touch $@

bin/sphinx-build: bin/pip
bin/pip install sphinx
$(VENV)/bin/sphinx-build: $(VENV)/bin/pip
$(VENV)/bin/pip install sphinx

docs: bin/sphinx-build
SPHINXBUILD=../bin/sphinx-build $(MAKE) -C docs html
docs: $(VENV)/bin/sphinx-build
SPHINXBUILD=../$(VENV)/bin/sphinx-build $(MAKE) -C docs html

# See setup.cfg for configuration.
isort:
Expand Down
15 changes: 9 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
.. image:: https://img.shields.io/pypi/v/pytest-django.svg?style=flat
:alt: PyPI Version
:target: https://pypi.python.org/pypi/pytest-django
.. image:: https://img.shields.io/codecov/c/github/pytest-dev/pytest-django.svg?style=flat
:alt: Coverage
:target: https://codecov.io/gh/pytest-dev/pytest-django

Welcome to pytest-django!
=========================

pytest-django allows you to test your Django project/applications with the
`pytest testing tool <http://pytest.org/>`_.
`pytest testing tool <https://pytest.org/>`_.

* `Quick start / tutorial
<https://pytest-django.readthedocs.io/en/latest/tutorial.html>`_
Expand All @@ -19,8 +22,8 @@ pytest-django allows you to test your Django project/applications with the
<https://pytest-django.readthedocs.io/en/latest/contributing.html>`_
* Version compatibility:

* Django: 1.7-1.10 and latest master branch (compatible at the time of each release)
* Python: CPython 2.7,3.3-3.5 or PyPy 2,3
* Django: 1.7-1.11 and latest master branch (compatible at the time of each release)
* Python: CPython 2.7,3.3-3.6 or PyPy 2,3
* pytest: >2.9.x

* Licence: BSD
Expand All @@ -43,11 +46,11 @@ Why would I use this instead of Django's `manage.py test` command?
Running your test suite with pytest-django allows you to tap into the features
that are already present in pytest. Here are some advantages:

* `Manage test dependencies with pytest fixtures. <http://pytest.org/latest/fixture.html>`_
* `Manage test dependencies with pytest fixtures. <https://pytest.org/en/latest/fixture.html>`_
* Less boilerplate tests: no need to import unittest, create a subclass with methods. Write tests as regular functions.
* Database re-use: no need to re-create the test database for every test run.
* Run tests in multiple processes for increased speed (with the pytest-xdist plugin).
* Make use of other `pytest plugins <http://pytest.org/latest/plugins.html>`_.
* Make use of other `pytest plugins <https://pytest.org/en/latest/plugins.html>`_.
* Works with both worlds: Existing unittest-style TestCase's still work without any modifications.

See the `pytest documentation <http://pytest.org/latest/>`_ for more information on pytest itself.
See the `pytest documentation <https://pytest.org/en/latest/>`_ for more information on pytest itself.
4 changes: 2 additions & 2 deletions docs/database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ what code uses the database and catches any mistakes.
Enabling database access in tests
---------------------------------

You can use `pytest marks <http://pytest.org/latest/mark.html>`_ to
You can use `pytest marks <https://pytest.org/en/latest/mark.html>`_ to
tell ``pytest-django`` your test needs database access::

import pytest
Expand All @@ -26,7 +26,7 @@ It is also possible to mark all tests in a class or module at once.
This demonstrates all the ways of marking, even though they overlap.
Just one of these marks would have been sufficient. See the `pytest
documentation
<http://pytest.org/latest/example/markers.html#marking-whole-classes-or-modules>`_
<https://pytest.org/en/latest/example/markers.html#marking-whole-classes-or-modules>`_
for detail::

import pytest
Expand Down
2 changes: 1 addition & 1 deletion docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ for more information.
How can I make sure that all my tests run with a specific locale?
-----------------------------------------------------------------

Create a `pytest fixture <http://pytest.org/latest/fixture.html>`_ that is
Create a `pytest fixture <https://pytest.org/en/latest/fixture.html>`_ that is
automatically run before each test case. To run all tests with the english
locale, put the following code in your project's `conftest.py`_ file:

Expand Down
8 changes: 4 additions & 4 deletions docs/helpers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Markers
``pytest-django`` registers and uses markers. See the pytest documentation_
on what marks are and for notes on using_ them.

.. _documentation: http://pytest.org/latest/mark.html
.. _using: http://pytest.org/latest/example/markers.html#marking-whole-classes-or-modules
.. _documentation: https://pytest.org/en/latest/mark.html
.. _using: https://pytest.org/en/latest/example/markers.html#marking-whole-classes-or-modules


``pytest.mark.django_db(transaction=False)`` - request database access
Expand Down Expand Up @@ -74,7 +74,7 @@ when trying to access the database.

@pytest.mark.urls('myapp.test_urls')
def test_something(client):
assert 'Success!' in client.get('/some_url_defined_in_test_urls/')
assert 'Success!' in client.get('/some_url_defined_in_test_urls/').content


``pytest.mark.ignore_template_errors`` - ignore invalid template variables
Expand All @@ -99,7 +99,7 @@ Fixtures

pytest-django provides some pytest fixtures to provide dependencies for tests.
More information on fixtures is available in the `pytest documentation
<http://pytest.org/latest/fixture.html>`_.
<https://pytest.org/en/latest/fixture.html>`_.


``rf`` - ``RequestFactory``
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pytest-django Documentation
pytest-django is a plugin for `pytest`_ that provides a set of useful tools
for testing `Django`_ applications and projects.

.. _pytest: http://pytest.org/
.. _pytest: https://pytest.org/
.. _Django: https://www.djangoproject.com/

Quick Start
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Talks, articles and blog posts
John Costa
<http://www.johnmcostaiii.net/2013/django-projects-to-django-apps-converting-the-unit-tests/>`_.

For general information and tutorials on pytest, see the `pytest tutorial page <http://pytest.org/latest/getting-started.html>`_.
For general information and tutorials on pytest, see the `pytest tutorial page <https://pytest.org/en/latest/getting-started.html>`_.


Step 1: Installation
Expand Down Expand Up @@ -88,7 +88,7 @@ The :ref:`usage` section describes more ways to interact with your test suites.
pytest-django also provides some :ref:`helpers` to make it easier to write
Django tests.

Consult the `pytest documentation <http://pytest.org/>`_ for more information
Consult the `pytest documentation <https://pytest.org/>`_ for more information
on pytest itself.

Stuck? Need help?
Expand Down
4 changes: 2 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ the command line::
pytest test_something.py a_directory

See the `pytest documentation on Usage and invocations
<http://pytest.org/latest/usage.html>`_ for more help on available parameters.
<https://pytest.org/en/latest/usage.html>`_ for more help on available parameters.

Additional command line options
-------------------------------
Expand Down Expand Up @@ -51,6 +51,6 @@ is set to "foo", the test database with xdist will be "test_foo_gw0",
"test_foo_gw1" etc.

See the full documentation on `pytest-xdist
<http://pytest.org/latest/xdist.html>`_ for more information. Among other
<https://pytest.org/en/latest/xdist.html>`_ for more information. Among other
features, pytest-xdist can distribute/coordinate test execution on remote
machines.
2 changes: 1 addition & 1 deletion pytest_django/lazy_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def skip_if_no_django():
"""Raises a skip exception when no Django settings are available"""
if not django_settings_is_configured():
pytest.skip('Test skipped since no Django settings is present.')
pytest.skip('no Django settings')


def django_settings_is_configured():
Expand Down
5 changes: 2 additions & 3 deletions pytest_django/live_server_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
class LiveServer(object):
"""The liveserver fixture
This is the object which is returned to the actual user when they
request the ``live_server`` fixture. The fixture handles creation
and stopping however.
This is the object that the ``live_server`` fixture returns.
The ``live_server`` fixture that handles creation and stopping.
"""

def __init__(self, addr):
Expand Down

0 comments on commit 5aa9790

Please sign in to comment.