commit python-pytest-django for openSUSE:Factory
Hello community, here is the log from the commit of package python-pytest-django for openSUSE:Factory checked in at 2019-11-03 11:39:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pytest-django (Old) and /work/SRC/openSUSE:Factory/.python-pytest-django.new.2990 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-pytest-django" Sun Nov 3 11:39:21 2019 rev:8 rq:744143 version:3.6.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pytest-django/python-pytest-django.changes 2019-08-23 11:08:01.286471160 +0200 +++ /work/SRC/openSUSE:Factory/.python-pytest-django.new.2990/python-pytest-django.changes 2019-11-03 11:39:22.634007607 +0100 @@ -1,0 +2,7 @@ +Wed Oct 30 11:54:08 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com> + +- Update to 3.6.0: + * Rename test databases when running parallel Tox (#678, #680) + * Django unittests: restore "debug" function (#769, #771) + +------------------------------------------------------------------- Old: ---- pytest-django-3.5.1.tar.gz New: ---- pytest-django-3.6.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pytest-django.spec ++++++ --- /var/tmp/diff_new_pack.pfsLgA/_old 2019-11-03 11:39:23.090008177 +0100 +++ /var/tmp/diff_new_pack.pfsLgA/_new 2019-11-03 11:39:23.094008182 +0100 @@ -18,11 +18,10 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-pytest-django -Version: 3.5.1 +Version: 3.6.0 Release: 0 Summary: A Django plugin for py.test License: BSD-3-Clause -Group: Development/Languages/Python URL: https://github.com/pytest-dev/pytest-django Source: https://files.pythonhosted.org/packages/source/p/pytest-django/pytest-django-%{version}.tar.gz BuildRequires: %{python_module Django} ++++++ pytest-django-3.5.1.tar.gz -> pytest-django-3.6.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/.gitignore new/pytest-django-3.6.0/.gitignore --- old/pytest-django-3.5.1/.gitignore 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/.gitignore 2019-10-17 03:07:43.000000000 +0200 @@ -9,6 +9,7 @@ .env /.coverage.* /.coverage +/coverage.xml /htmlcov/ .cache .pytest_cache/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/.travis.yml new/pytest-django-3.6.0/.travis.yml --- old/pytest-django-3.5.1/.travis.yml 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/.travis.yml 2019-10-17 03:07:43.000000000 +0200 @@ -6,7 +6,10 @@ include: - stage: baseline python: 3.6 - env: TOXENV=py36-dj20-postgres-xdist-coverage + env: + - TOXENV=py36-dj20-postgres-xdist-coverage + # Test in verbose mode. + - PYTEST_ADDOPTS=-vv services: - postgresql - python: 3.6 @@ -23,6 +26,8 @@ env: TOXENV=py37-dj21-sqlite-coverage - python: 3.7 env: TOXENV=py37-dj22-sqlite-xdist-coverage + - python: 3.8-dev + env: TOXENV=py38-dj30-sqlite-xdist-coverage # Explicitly test (older) pytest 4.1. - python: 3.7 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/PKG-INFO new/pytest-django-3.6.0/PKG-INFO --- old/pytest-django-3.5.1/PKG-INFO 2019-06-29 18:28:42.000000000 +0200 +++ new/pytest-django-3.6.0/PKG-INFO 2019-10-17 03:07:59.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pytest-django -Version: 3.5.1 +Version: 3.6.0 Summary: A Django plugin for pytest. Home-page: https://pytest-django.readthedocs.io/ Author: Andreas Pelme diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/codecov.yml new/pytest-django-3.6.0/codecov.yml --- old/pytest-django-3.5.1/codecov.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-django-3.6.0/codecov.yml 2019-10-17 03:07:43.000000000 +0200 @@ -0,0 +1,6 @@ +coverage: + status: + project: true + patch: true + changes: true +comment: false diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/docs/changelog.rst new/pytest-django-3.6.0/docs/changelog.rst --- old/pytest-django-3.5.1/docs/changelog.rst 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/docs/changelog.rst 2019-10-17 03:07:43.000000000 +0200 @@ -1,6 +1,25 @@ Changelog ========= +3.6.0 (2019-10-17) +------------------ + +Features +^^^^^^^^ + +* Rename test databases when running parallel Tox (#678, #680) + +Bugfixes +^^^^^^^^ + +* Django unittests: restore "debug" function (#769, #771) + +Misc +^^^^ + +* Improve/harden internal tests / infrastructure. + + 3.5.1 (2019-06-29) ------------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/docs/database.rst new/pytest-django-3.6.0/docs/database.rst --- old/pytest-django-3.5.1/docs/database.rst 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/docs/database.rst 2019-10-17 03:07:43.000000000 +0200 @@ -191,21 +191,43 @@ fixture you want to override. The default implementation of this fixture requests the -:fixture:`django_db_modify_db_settings_xdist_suffix` to provide compatibility +:fixture:`django_db_modify_db_settings_parallel_suffix` to provide compatibility with pytest-xdist. This fixture is by default requested from :fixture:`django_db_setup`. +django_db_modify_db_settings_parallel_suffix +"""""""""""""""""""""""""""""""""""""""""""" + +.. fixture:: django_db_modify_db_settings_parallel_suffix + +Requesting this fixture will add a suffix to the database name when the tests +are run via `pytest-xdist`, or via `tox` in parallel mode. + +This fixture is by default requested from +:fixture:`django_db_modify_db_settings`. + +django_db_modify_db_settings_tox_suffix +""""""""""""""""""""""""""""""""""""""" + +.. fixture:: django_db_modify_db_settings_tox_suffix + +Requesting this fixture will add a suffix to the database name when the tests +are run via `tox` in parallel mode. + +This fixture is by default requested from +:fixture:`django_db_modify_db_settings_parallel_suffix`. + django_db_modify_db_settings_xdist_suffix """"""""""""""""""""""""""""""""""""""""" .. fixture:: django_db_modify_db_settings_xdist_suffix Requesting this fixture will add a suffix to the database name when the tests -are run via pytest-xdist. +are run via `pytest-xdist`. This fixture is by default requested from -:fixture:`django_db_modify_db_settings`. +:fixture:`django_db_modify_db_settings_parallel_suffix`. django_db_use_migrations """""""""""""""""""""""" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/docs/tutorial.rst new/pytest-django-3.6.0/docs/tutorial.rst --- old/pytest-django-3.5.1/docs/tutorial.rst 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/docs/tutorial.rst 2019-10-17 03:07:43.000000000 +0200 @@ -19,7 +19,7 @@ * Blog post: `Django Projects to Django Apps: Converting the Unit Tests, by John Costa - <http://www.johnmcostaiii.net/2013/django-projects-to-django-apps-converting-the-unit-tests/>`_. + <https://www.johnmcostaiii.net/post/2013-04-21-django-projects-to-django-apps-converting-the-unit-tests/>`_. For general information and tutorials on pytest, see the `pytest tutorial page <https://pytest.org/en/latest/getting-started.html>`_. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/pytest_django/fixtures.py new/pytest-django-3.6.0/pytest_django/fixtures.py --- old/pytest-django-3.5.1/pytest_django/fixtures.py 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/pytest_django/fixtures.py 2019-10-17 03:07:43.000000000 +0200 @@ -33,35 +33,35 @@ @pytest.fixture(scope="session") -def django_db_modify_db_settings_xdist_suffix(request): +def django_db_modify_db_settings_tox_suffix(request): skip_if_no_django() - from django.conf import settings - - for db_settings in settings.DATABASES.values(): - - try: - test_name = db_settings["TEST"]["NAME"] - except KeyError: - test_name = None + tox_environment = os.getenv("TOX_PARALLEL_ENV") + if tox_environment: + # Put a suffix like _py27-django21 on tox workers + _set_suffix_to_test_databases(suffix=tox_environment) - if not test_name: - if db_settings["ENGINE"] == "django.db.backends.sqlite3": - continue - test_name = "test_{}".format(db_settings["NAME"]) +@pytest.fixture(scope="session") +def django_db_modify_db_settings_xdist_suffix(request): + skip_if_no_django() + xdist_suffix = getattr(request.config, "slaveinput", {}).get("slaveid") + if xdist_suffix: # Put a suffix like _gw0, _gw1 etc on xdist processes - xdist_suffix = getattr(request.config, "slaveinput", {}).get("slaveid") - if test_name != ":memory:" and xdist_suffix is not None: - test_name = "{}_{}".format(test_name, xdist_suffix) + _set_suffix_to_test_databases(suffix=xdist_suffix) - db_settings.setdefault("TEST", {}) - db_settings["TEST"]["NAME"] = test_name + +@pytest.fixture(scope="session") +def django_db_modify_db_settings_parallel_suffix( + django_db_modify_db_settings_tox_suffix, + django_db_modify_db_settings_xdist_suffix, +): + skip_if_no_django() @pytest.fixture(scope="session") -def django_db_modify_db_settings(django_db_modify_db_settings_xdist_suffix): +def django_db_modify_db_settings(django_db_modify_db_settings_parallel_suffix): skip_if_no_django() @@ -169,6 +169,24 @@ migrate.Command = MigrateSilentCommand +def _set_suffix_to_test_databases(suffix): + from django.conf import settings + + for db_settings in settings.DATABASES.values(): + test_name = db_settings.get("TEST", {}).get("NAME") + + if not test_name: + if db_settings["ENGINE"] == "django.db.backends.sqlite3": + continue + test_name = "test_{}".format(db_settings["NAME"]) + + if test_name == ":memory:": + continue + + db_settings.setdefault("TEST", {}) + db_settings["TEST"]["NAME"] = "{}_{}".format(test_name, suffix) + + # ############### User visible fixtures ################ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/pytest_django/plugin.py new/pytest-django-3.6.0/pytest_django/plugin.py --- old/pytest-django-3.5.1/pytest_django/plugin.py 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/pytest_django/plugin.py 2019-10-17 03:07:43.000000000 +0200 @@ -22,6 +22,8 @@ from .fixtures import django_db_keepdb # noqa from .fixtures import django_db_createdb # noqa from .fixtures import django_db_modify_db_settings # noqa +from .fixtures import django_db_modify_db_settings_parallel_suffix # noqa +from .fixtures import django_db_modify_db_settings_tox_suffix # noqa from .fixtures import django_db_modify_db_settings_xdist_suffix # noqa from .fixtures import _live_server_helper # noqa from .fixtures import admin_client # noqa @@ -520,8 +522,9 @@ cls = request.node.cls - # implement missing (as of 1.10) debug() method for django's TestCase - # see pytest-dev/pytest-django#406 + # Implement missing (as of 2.2) debug() wrapper/method for Django's TestCase. + # See pytest-dev/pytest-django#406. + # Pending PR for Django: https://github.com/django/django/pull/7436. def _cleaning_debug(self): testMethod = getattr(self, self._testMethodName) skipped = getattr(self.__class__, "__unittest_skip__", False) or getattr( @@ -534,6 +537,7 @@ if not skipped: self._post_teardown() + orig_debug = cls.debug cls.debug = _cleaning_debug with django_db_blocker.unblock(): @@ -549,6 +553,8 @@ else: yield + cls.debug = orig_debug + @pytest.fixture(scope="function", autouse=True) def _dj_autoclear_mailbox(): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/pytest_django.egg-info/PKG-INFO new/pytest-django-3.6.0/pytest_django.egg-info/PKG-INFO --- old/pytest-django-3.5.1/pytest_django.egg-info/PKG-INFO 2019-06-29 18:28:42.000000000 +0200 +++ new/pytest-django-3.6.0/pytest_django.egg-info/PKG-INFO 2019-10-17 03:07:59.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pytest-django -Version: 3.5.1 +Version: 3.6.0 Summary: A Django plugin for pytest. Home-page: https://pytest-django.readthedocs.io/ Author: Andreas Pelme diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/pytest_django.egg-info/SOURCES.txt new/pytest-django-3.6.0/pytest_django.egg-info/SOURCES.txt --- old/pytest-django-3.5.1/pytest_django.egg-info/SOURCES.txt 2019-06-29 18:28:42.000000000 +0200 +++ new/pytest-django-3.6.0/pytest_django.egg-info/SOURCES.txt 2019-10-17 03:07:59.000000000 +0200 @@ -6,6 +6,7 @@ MANIFEST.in Makefile README.rst +codecov.yml requirements.txt setup.cfg setup.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/pytest_django_test/compat.py new/pytest-django-3.6.0/pytest_django_test/compat.py --- old/pytest-django-3.5.1/pytest_django_test/compat.py 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/pytest_django_test/compat.py 2019-10-17 03:07:43.000000000 +0200 @@ -1,13 +1,4 @@ try: - from urllib2 import urlopen, HTTPError # noqa + from urllib2 import urlopen, HTTPError except ImportError: - from urllib.request import urlopen, HTTPError # noqa - -# Django 1.10 removes patterns, instead it is just a list -try: - from django.conf.urls import patterns -except ImportError: - - def patterns(prefix, *urls): - assert prefix == "" - return urls + from urllib.request import urlopen, HTTPError # noqa: F401 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/pytest_django_test/urls.py new/pytest-django-3.6.0/pytest_django_test/urls.py --- old/pytest-django-3.5.1/pytest_django_test/urls.py 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/pytest_django_test/urls.py 2019-10-17 03:07:43.000000000 +0200 @@ -1,10 +1,8 @@ from django.conf.urls import url from .app import views -from .compat import patterns -urlpatterns = patterns( - "", +urlpatterns = [ url(r"^item_count/$", views.item_count), url(r"^admin-required/$", views.admin_required_view), -) +] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/pytest_django_test/urls_overridden.py new/pytest-django-3.6.0/pytest_django_test/urls_overridden.py --- old/pytest-django-3.5.1/pytest_django_test/urls_overridden.py 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/pytest_django_test/urls_overridden.py 2019-10-17 03:07:43.000000000 +0200 @@ -1,8 +1,6 @@ from django.conf.urls import url from django.http import HttpResponse -from .compat import patterns - -urlpatterns = patterns( - "", url(r"^overridden_url/$", lambda r: HttpResponse("Overridden urlconf works!")) -) +urlpatterns = [ + url(r"^overridden_url/$", lambda r: HttpResponse("Overridden urlconf works!")) +] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/tests/test_db_setup.py new/pytest-django-3.6.0/tests/test_db_setup.py --- old/pytest-django-3.5.1/tests/test_db_setup.py 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/tests/test_db_setup.py 2019-10-17 03:07:43.000000000 +0200 @@ -288,7 +288,135 @@ assert conn_db2.vendor == 'sqlite' db_name = conn_db2.creation._get_test_db_name() - assert 'test_custom_db_name_gw' in db_name + assert db_name.startswith('test_custom_db_name_gw') + """ + ) + + result = django_testdir.runpytest_subprocess("--tb=short", "-vv", "-n1") + assert result.ret == 0 + result.stdout.fnmatch_lines(["*PASSED*test_a*"]) + + +class TestSqliteWithTox: + + db_settings = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": "db_name", + "TEST": {"NAME": "test_custom_db_name"}, + } + } + + def test_db_with_tox_suffix(self, django_testdir, monkeypatch): + "A test to check that Tox DB suffix works when running in parallel." + monkeypatch.setenv("TOX_PARALLEL_ENV", "py37-django22") + + django_testdir.create_test_module( + """ + import pytest + from django.db import connections + + @pytest.mark.django_db + def test_inner(): + + (conn, ) = connections.all() + + assert conn.vendor == 'sqlite' + db_name = conn.creation._get_test_db_name() + assert db_name == 'test_custom_db_name_py37-django22' + """ + ) + + result = django_testdir.runpytest_subprocess("--tb=short", "-vv") + assert result.ret == 0 + result.stdout.fnmatch_lines(["*test_inner*PASSED*"]) + + def test_db_with_empty_tox_suffix(self, django_testdir, monkeypatch): + "A test to check that Tox DB suffix is not used when suffix would be empty." + monkeypatch.setenv("TOX_PARALLEL_ENV", "") + + django_testdir.create_test_module( + """ + import pytest + from django.db import connections + + @pytest.mark.django_db + def test_inner(): + + (conn,) = connections.all() + + assert conn.vendor == 'sqlite' + db_name = conn.creation._get_test_db_name() + assert db_name == 'test_custom_db_name' + """ + ) + + result = django_testdir.runpytest_subprocess("--tb=short", "-vv") + assert result.ret == 0 + result.stdout.fnmatch_lines(["*test_inner*PASSED*"]) + + +class TestSqliteWithToxAndXdist: + + db_settings = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": "db_name", + "TEST": {"NAME": "test_custom_db_name"}, + } + } + + def test_db_with_tox_suffix(self, django_testdir, monkeypatch): + "A test to check that both Tox and xdist suffixes work together." + pytest.importorskip("xdist") + monkeypatch.setenv("TOX_PARALLEL_ENV", "py37-django22") + + django_testdir.create_test_module( + """ + import pytest + from django.db import connections + + @pytest.mark.django_db + def test_inner(): + + (conn, ) = connections.all() + + assert conn.vendor == 'sqlite' + db_name = conn.creation._get_test_db_name() + assert db_name.startswith('test_custom_db_name_py37-django22_gw') + """ + ) + + result = django_testdir.runpytest_subprocess("--tb=short", "-vv", "-n1") + assert result.ret == 0 + result.stdout.fnmatch_lines(["*PASSED*test_inner*"]) + + +class TestSqliteInMemoryWithXdist: + + db_settings = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": ":memory:", + "TEST": {"NAME": ":memory:"}, + } + } + + def test_sqlite_in_memory_used(self, django_testdir): + pytest.importorskip("xdist") + + django_testdir.create_test_module( + """ + import pytest + from django.db import connections + + @pytest.mark.django_db + def test_a(): + (conn, ) = connections.all() + + assert conn.vendor == 'sqlite' + db_name = conn.creation._get_test_db_name() + assert 'file:memorydb' in db_name or db_name == ':memory:' """ ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/tests/test_django_configurations.py new/pytest-django-3.6.0/tests/test_django_configurations.py --- old/pytest-django-3.5.1/tests/test_django_configurations.py 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/tests/test_django_configurations.py 2019-10-17 03:07:43.000000000 +0200 @@ -40,7 +40,7 @@ """ ) result = testdir.runpytest_subprocess() - result.stdout.fnmatch_lines(["*1 passed*"]) + result.stdout.fnmatch_lines(["* 1 passed in*"]) assert result.ret == 0 @@ -68,7 +68,7 @@ """ ) result = testdir.runpytest_subprocess() - result.stdout.fnmatch_lines(["*1 passed*"]) + result.stdout.fnmatch_lines(["* 1 passed in*"]) assert result.ret == 0 @@ -96,5 +96,5 @@ """ ) result = testdir.runpytest_subprocess("--ds=tpkg.settings_opt", "--dc=MySettings") - result.stdout.fnmatch_lines(["*1 passed*"]) + result.stdout.fnmatch_lines(["* 1 passed in*"]) assert result.ret == 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/tests/test_django_settings_module.py new/pytest-django-3.6.0/tests/test_django_settings_module.py --- old/pytest-django-3.5.1/tests/test_django_settings_module.py 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/tests/test_django_settings_module.py 2019-10-17 03:07:43.000000000 +0200 @@ -138,7 +138,7 @@ testdir.makepyfile(settings_after_conftest="SECRET_KEY='secret'") # testdir.makeconftest("import sys; print(sys.path)") result = testdir.runpytest_subprocess("-v") - result.stdout.fnmatch_lines(["*1 passed*"]) + result.stdout.fnmatch_lines(["* 1 passed in*"]) assert result.ret == 0 @@ -226,7 +226,7 @@ """ ) result = testdir.runpython(p) - result.stdout.fnmatch_lines(["*4 passed*"]) + result.stdout.fnmatch_lines(["* 4 passed in*"]) def test_settings_in_hook(testdir, monkeypatch): @@ -275,7 +275,7 @@ """ ) result = testdir.runpytest_subprocess() - result.stdout.fnmatch_lines(["*1 passed*"]) + result.stdout.fnmatch_lines(["* 1 passed in*"]) assert result.ret == 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/tests/test_environment.py new/pytest-django-3.6.0/tests/test_environment.py --- old/pytest-django-3.5.1/tests/test_environment.py 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/tests/test_environment.py 2019-10-17 03:07:43.000000000 +0200 @@ -58,14 +58,10 @@ django_testdir.create_app_file( """ from django.conf.urls import url - from pytest_django_test.compat import patterns from tpkg.app import views - urlpatterns = patterns( - '', - url(r'invalid_template/', views.invalid_template), - ) + urlpatterns = [url(r'invalid_template/', views.invalid_template)] """, "urls.py", ) @@ -168,14 +164,10 @@ django_testdir.create_app_file( """ from django.conf.urls import url - from pytest_django_test.compat import patterns from tpkg.app import views - urlpatterns = patterns( - '', - url(r'invalid_template/', views.invalid_template), - ) + urlpatterns = [url(r'invalid_template/', views.invalid_template)] """, "urls.py", ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/tests/test_fixtures.py new/pytest-django-3.6.0/tests/test_fixtures.py --- old/pytest-django-3.5.1/tests/test_fixtures.py 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/tests/test_fixtures.py 2019-10-17 03:07:43.000000000 +0200 @@ -7,12 +7,12 @@ from __future__ import with_statement import socket +from contextlib import contextmanager import pytest - -from django.db import connection, transaction from django.conf import settings as real_settings from django.core import mail +from django.db import connection, transaction from django.test.client import Client, RequestFactory from django.test.testcases import connections_support_transactions from django.utils.encoding import force_text @@ -22,6 +22,18 @@ from pytest_django_test.compat import HTTPError, urlopen +@contextmanager +def nonverbose_config(config): + """Ensure that pytest's config.option.verbose is <= 0.""" + if config.option.verbose <= 0: + yield + else: + saved = config.option.verbose + config.option.verbose = 0 + yield + config.option.verbose = saved + + def test_client(client): assert isinstance(client, Client) @@ -53,56 +65,58 @@ @pytest.mark.django_db -def test_django_assert_num_queries_db(django_assert_num_queries): - with django_assert_num_queries(3): - Item.objects.create(name="foo") - Item.objects.create(name="bar") - Item.objects.create(name="baz") +def test_django_assert_num_queries_db(request, django_assert_num_queries): + with nonverbose_config(request.config): + with django_assert_num_queries(3): + Item.objects.create(name="foo") + Item.objects.create(name="bar") + Item.objects.create(name="baz") - with pytest.raises(pytest.fail.Exception) as excinfo: - with django_assert_num_queries(2) as captured: - Item.objects.create(name="quux") - assert excinfo.value.args == ( - "Expected to perform 2 queries but 1 was done " - "(add -v option to show queries)", - ) - assert len(captured.captured_queries) == 1 + with pytest.raises(pytest.fail.Exception) as excinfo: + with django_assert_num_queries(2) as captured: + Item.objects.create(name="quux") + assert excinfo.value.args == ( + "Expected to perform 2 queries but 1 was done " + "(add -v option to show queries)", + ) + assert len(captured.captured_queries) == 1 @pytest.mark.django_db -def test_django_assert_max_num_queries_db(django_assert_max_num_queries): - with django_assert_max_num_queries(2): - Item.objects.create(name="1-foo") - Item.objects.create(name="2-bar") - - with pytest.raises(pytest.fail.Exception) as excinfo: - with django_assert_max_num_queries(2) as captured: +def test_django_assert_max_num_queries_db(request, django_assert_max_num_queries): + with nonverbose_config(request.config): + with django_assert_max_num_queries(2): Item.objects.create(name="1-foo") Item.objects.create(name="2-bar") - Item.objects.create(name="3-quux") - assert excinfo.value.args == ( - "Expected to perform 2 queries or less but 3 were done " - "(add -v option to show queries)", - ) - assert len(captured.captured_queries) == 3 - assert "1-foo" in captured.captured_queries[0]["sql"] + with pytest.raises(pytest.fail.Exception) as excinfo: + with django_assert_max_num_queries(2) as captured: + Item.objects.create(name="1-foo") + Item.objects.create(name="2-bar") + Item.objects.create(name="3-quux") + + assert excinfo.value.args == ( + "Expected to perform 2 queries or less but 3 were done " + "(add -v option to show queries)", + ) + assert len(captured.captured_queries) == 3 + assert "1-foo" in captured.captured_queries[0]["sql"] @pytest.mark.django_db(transaction=True) def test_django_assert_num_queries_transactional_db( - transactional_db, django_assert_num_queries + request, transactional_db, django_assert_num_queries ): - with transaction.atomic(): - - with django_assert_num_queries(3): - Item.objects.create(name="foo") - Item.objects.create(name="bar") - Item.objects.create(name="baz") - - with pytest.raises(pytest.fail.Exception): - with django_assert_num_queries(2): - Item.objects.create(name="quux") + with nonverbose_config(request.config): + with transaction.atomic(): + with django_assert_num_queries(3): + Item.objects.create(name="foo") + Item.objects.create(name="bar") + Item.objects.create(name="baz") + + with pytest.raises(pytest.fail.Exception): + with django_assert_num_queries(2): + Item.objects.create(name="quux") def test_django_assert_num_queries_output(django_testdir): @@ -504,13 +518,9 @@ django_testdir.create_app_file( """ from django.conf.urls import url - from pytest_django_test.compat import patterns from tpkg.app import views - urlpatterns = patterns( - '', - url(r'admin-required/', views.admin_required_view), - ) + urlpatterns = [url(r'admin-required/', views.admin_required_view)] """, "urls.py", ) @@ -529,12 +539,12 @@ ) django_testdir.makepyfile( """ - from django.utils.encoding import force_text + from django.utils.encoding import force_str from tpkg.app.models import MyCustomUser def test_custom_user_model(admin_client): resp = admin_client.get('/admin-required/') - assert force_text(resp.content) == 'You are an admin' + assert force_str(resp.content) == 'You are an admin' """ ) @@ -564,7 +574,7 @@ ('password', models.CharField(max_length=128, verbose_name='password')), ('last_login', models.DateTimeField(null=True, verbose_name='last login', blank=True)), ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), - ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, max_length=30, validators=[django.core.validators.RegexValidator('^[\\w.@+-]+$', 'Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.', 'invalid')], help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.', unique=True, verbose_name='username')), + ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, max_length=30, validators=[django.core.validators.RegexValidator(r'^[\\w.@+-]+$', 'Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.', 'invalid')], help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.', unique=True, verbose_name='username')), ('first_name', models.CharField(max_length=30, verbose_name='first name', blank=True)), ('last_name', models.CharField(max_length=30, verbose_name='last name', blank=True)), ('email', models.EmailField(max_length=254, verbose_name='email address', blank=True)), @@ -588,7 +598,7 @@ ) result = django_testdir.runpytest_subprocess("-s") - result.stdout.fnmatch_lines(["*1 passed*"]) + result.stdout.fnmatch_lines(["* 1 passed in*"]) assert result.ret == 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/tests/test_initialization.py new/pytest-django-3.6.0/tests/test_initialization.py --- old/pytest-django-3.5.1/tests/test_initialization.py 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/tests/test_initialization.py 2019-10-17 03:07:43.000000000 +0200 @@ -54,7 +54,7 @@ "conftest", "pytest_configure: conftest", "pytest_configure: plugin", - "*1 passed*", + "* 1 passed in*", ] ) assert result.ret == 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/tests/test_unittest.py new/pytest-django-3.6.0/tests/test_unittest.py --- old/pytest-django-3.5.1/tests/test_unittest.py 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/tests/test_unittest.py 2019-10-17 03:07:43.000000000 +0200 @@ -392,7 +392,7 @@ result = django_testdir.runpytest_subprocess("-q", "-s") result.stdout.fnmatch_lines( - ["*FooBarTestCase.setUpClass*", "*test_noop*", "1 passed*"] + ["*FooBarTestCase.setUpClass*", "*test_noop*", "1 passed in*"] ) assert result.ret == 0 @@ -456,3 +456,34 @@ result = django_testdir.runpytest_subprocess("-v", "--pdb") assert result.ret == 0 + + +def test_debug_restored(django_testdir): + django_testdir.create_test_module( + """ + from django.test import TestCase + + pre_setup_count = 0 + + + class TestClass1(TestCase): + + def test_method(self): + pass + + + class TestClass2(TestClass1): + + def _pre_setup(self): + global pre_setup_count + pre_setup_count += 1 + super(TestClass2, self)._pre_setup() + + def test_method(self): + assert pre_setup_count == 1 + """ + ) + + result = django_testdir.runpytest_subprocess("--pdb") + result.stdout.fnmatch_lines(["*= 2 passed in *"]) + assert result.ret == 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/tests/test_urls.py new/pytest-django-3.6.0/tests/test_urls.py --- old/pytest-django-3.5.1/tests/test_urls.py 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/tests/test_urls.py 2019-10-17 03:07:43.000000000 +0200 @@ -23,12 +23,11 @@ testdir.makepyfile( myurls=""" from django.conf.urls import url - from pytest_django_test.compat import patterns def fake_view(request): pass - urlpatterns = patterns('', url(r'first/$', fake_view, name='first')) + urlpatterns = [url(r'first/$', fake_view, name='first')] """ ) @@ -60,24 +59,22 @@ testdir.makepyfile( myurls=""" from django.conf.urls import url - from pytest_django_test.compat import patterns def fake_view(request): pass - urlpatterns = patterns('', url(r'first/$', fake_view, name='first')) + urlpatterns = [url(r'first/$', fake_view, name='first')] """ ) testdir.makepyfile( myurls2=""" from django.conf.urls import url - from pytest_django_test.compat import patterns def fake_view(request): pass - urlpatterns = patterns('', url(r'second/$', fake_view, name='second')) + urlpatterns = [url(r'second/$', fake_view, name='second')] """ ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-django-3.5.1/tox.ini new/pytest-django-3.6.0/tox.ini --- old/pytest-django-3.5.1/tox.ini 2019-06-29 18:28:26.000000000 +0200 +++ new/pytest-django-3.6.0/tox.ini 2019-10-17 03:07:43.000000000 +0200 @@ -1,7 +1,8 @@ [tox] envlist = - py{37}-dj{22,21,20,111}-postgres - py{35,36}-dj{22,21,20,111,110,19,18}-postgres + py37-dj{30,22,21,20,111}-postgres + py36-dj{30,22,21,20,111,110,19,18}-postgres + py35-dj{22,21,20,111,110,19,18}-postgres py34-dj{20,111,110}-postgres py27-dj{111,110}-{mysql_innodb,mysql_myisam,postgres} py27-dj{111,110,19,18}-postgres @@ -11,6 +12,7 @@ extras = testing deps = djmaster: https://github.com/django/django/archive/master.tar.gz + dj30: Django>=3.0a1,<3.1 dj22: Django>=2.2a1,<2.3 dj21: Django>=2.1,<2.2 dj20: Django>=2.0,<2.1 @@ -26,6 +28,7 @@ coverage: coverage-enable-subprocess pytest41: pytest>=4.1,<4.2 + pytest41: attrs==17.4.0 xdist: pytest-xdist>=1.15 setenv = @@ -42,7 +45,7 @@ coverage: COVERAGE_FILE={toxinidir}/.coverage coverage: PYTESTDJANGO_COVERAGE_SRC={toxinidir}/ -passenv = PYTEST_ADDOPTS +passenv = PYTEST_ADDOPTS TERM usedevelop = True commands = coverage: coverage erase
participants (1)
-
root