Hello community,
here is the log from the commit of package python-pytest-django for
openSUSE:Factory checked in at 2019-06-17 21:34:46
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pytest-django (Old)
and /work/SRC/openSUSE:Factory/.python-pytest-django.new.4811 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pytest-django"
Mon Jun 17 21:34:46 2019 rev:5 rq:710346 version:3.5.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-pytest-django/python-pytest-django.changes
2019-03-01 16:47:03.693807359 +0100
+++
/work/SRC/openSUSE:Factory/.python-pytest-django.new.4811/python-pytest-django.changes
2019-06-17 21:35:17.514997845 +0200
@@ -1,0 +2,12 @@
+Mon Jun 17 12:07:05 UTC 2019 - Tomáš Chvátal <[email protected]>
+
+- Update to 3.5.0:
+ * Run tests in the same order as Django (#223)
+ * Use verbosity=0 with disabled migrations (#729, #730)
+ * django_db_setup: warn instead of crash with teardown errors (#726)
+ * tests: fix test_sqlite_database_renamed (#739, #741)
+ * tests/conftest.py: move import of db_helpers (#737)
+ * Cleanup/improve coverage, mainly with tests (#706)
+ * Slightly revisit unittest handling (#740)
+
+-------------------------------------------------------------------
Old:
----
pytest-django-3.4.8.tar.gz
New:
----
pytest-django-3.5.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pytest-django.spec ++++++
--- /var/tmp/diff_new_pack.aDCMBT/_old 2019-06-17 21:35:17.894997759 +0200
+++ /var/tmp/diff_new_pack.aDCMBT/_new 2019-06-17 21:35:17.898997758 +0200
@@ -18,7 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-pytest-django
-Version: 3.4.8
+Version: 3.5.0
Release: 0
Summary: A Django plugin for py.test
License: BSD-3-Clause
@@ -71,7 +71,7 @@
%check
# memory operations failed in OBS not localy, thus skip them
export DJANGO_SETTINGS_MODULE=pytest_django_test.settings_sqlite
-%python_expand PYTHONPATH=$(pwd) py.test-%{$python_bin_suffix} tests/ -k 'not
test_sqlite_in_memory_used'
+%python_expand PYTHONPATH=$(pwd) py.test-%{$python_bin_suffix} -v tests/ -k
'not (test_sqlite_in_memory_used or test_django_assert_num_queries_db or
test_django_assert_max_num_queries_db)'
%files %{python_files}
%license LICENSE
++++++ pytest-django-3.4.8.tar.gz -> pytest-django-3.5.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-django-3.4.8/.travis.yml
new/pytest-django-3.5.0/.travis.yml
--- old/pytest-django-3.4.8/.travis.yml 2019-02-26 16:02:52.000000000 +0100
+++ new/pytest-django-3.5.0/.travis.yml 2019-06-03 16:24:31.000000000 +0200
@@ -10,11 +10,11 @@
services:
- postgresql
- python: 3.6
- env: TOXENV=py36-dj111-sqlite-coverage
- - python: 2.7
- env: TOXENV=py27-dj111-mysql_innodb-coverage
+ env: TOXENV=py36-dj111-mysql_innodb-coverage
services:
- mysql
+ - python: 2.7
+ env: TOXENV=py27-dj111-sqlite-xdist-coverage
- python: 3.6
env: TOXENV=checkqa,docs
@@ -22,7 +22,7 @@
python: 3.7
env: TOXENV=py37-dj21-sqlite-coverage
- python: 3.7
- env: TOXENV=py37-dj22-sqlite-coverage
+ env: TOXENV=py37-dj22-sqlite-xdist-coverage
# Explicitly test (older) pytest 4.1.
- python: 3.7
@@ -49,9 +49,9 @@
- postgresql
# pypy/pypy3: not included with coverage reports (much slower then).
- - python: pypy2.7-6.0
+ - python: pypy
env: TOXENV=pypy-dj111-sqlite_file
- - python: pypy3.5-6.0
+ - python: pypy3
env: TOXENV=pypy3-dj110-sqlite
- stage: test_release
@@ -98,8 +98,6 @@
- |
set -ex
if [[ "${TOXENV%-coverage}" != "$TOXENV" ]]; then
- codecov_flags=${TOXENV%-coverage}
- codecov_flags=${codecov_flags//-/,}
- bash <(curl -s https://codecov.io/bash) -Z -X gcov -X xcode -X gcovout
-F "$codecov_flags"
+ bash <(curl -s https://codecov.io/bash) -Z -X gcov -X xcode -X gcovout
fi
- set +x
+ set +ex
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-django-3.4.8/PKG-INFO
new/pytest-django-3.5.0/PKG-INFO
--- old/pytest-django-3.4.8/PKG-INFO 2019-02-26 16:03:07.000000000 +0100
+++ new/pytest-django-3.5.0/PKG-INFO 2019-06-03 16:24:46.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: pytest-django
-Version: 3.4.8
+Version: 3.5.0
Summary: A Django plugin for pytest.
Home-page: https://pytest-django.readthedocs.io/
Author: Andreas Pelme
@@ -95,5 +95,5 @@
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
-Provides-Extra: docs
Provides-Extra: testing
+Provides-Extra: docs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-django-3.4.8/docs/conf.py
new/pytest-django-3.5.0/docs/conf.py
--- old/pytest-django-3.4.8/docs/conf.py 2019-02-26 16:02:52.000000000
+0100
+++ new/pytest-django-3.5.0/docs/conf.py 2019-06-03 16:24:31.000000000
+0200
@@ -50,7 +50,7 @@
def setup(app):
# Allow linking to pytest's confvals.
- app.add_description_unit(
+ app.add_object_type(
"confval",
"pytest-confval",
objname="configuration value",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-django-3.4.8/docs/database.rst
new/pytest-django-3.5.0/docs/database.rst
--- old/pytest-django-3.4.8/docs/database.rst 2019-02-26 16:02:52.000000000
+0100
+++ new/pytest-django-3.5.0/docs/database.rst 2019-06-03 16:24:31.000000000
+0200
@@ -143,7 +143,7 @@
however influence all parts of the database setup process to make it fit in
projects with special requirements.
-This section assumes some familiary with the Django test runner, Django
+This section assumes some familiarity with the Django test runner, Django
database creation and pytest fixtures.
Fixtures
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-django-3.4.8/pytest_django/fixtures.py
new/pytest-django-3.5.0/pytest_django/fixtures.py
--- old/pytest-django-3.4.8/pytest_django/fixtures.py 2019-02-26
16:02:52.000000000 +0100
+++ new/pytest-django-3.5.0/pytest_django/fixtures.py 2019-06-03
16:24:31.000000000 +0200
@@ -110,7 +110,14 @@
def teardown_database():
with django_db_blocker.unblock():
- teardown_databases(db_cfg, verbosity=request.config.option.verbose)
+ try:
+ teardown_databases(db_cfg,
verbosity=request.config.option.verbose)
+ except Exception as exc:
+ request.node.warn(
+ pytest.PytestWarning(
+ "Error when trying to teardown test databases: %r" %
exc
+ )
+ )
if not django_db_keepdb:
request.addfinalizer(teardown_database)
@@ -148,10 +155,19 @@
def _disable_native_migrations():
from django.conf import settings
+ from django.core.management.commands import migrate
+
from .migrations import DisableMigrations
settings.MIGRATION_MODULES = DisableMigrations()
+ class MigrateSilentCommand(migrate.Command):
+ def handle(self, *args, **kwargs):
+ kwargs["verbosity"] = 0
+ return super(MigrateSilentCommand, self).handle(*args, **kwargs)
+
+ migrate.Command = MigrateSilentCommand
+
# ############### User visible fixtures ################
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-django-3.4.8/pytest_django/plugin.py
new/pytest-django-3.5.0/pytest_django/plugin.py
--- old/pytest-django-3.4.8/pytest_django/plugin.py 2019-02-26
16:02:52.000000000 +0100
+++ new/pytest-django-3.5.0/pytest_django/plugin.py 2019-06-03
16:24:31.000000000 +0200
@@ -245,14 +245,14 @@
early_config.addinivalue_line(
"markers",
"django_db(transaction=False): Mark the test as using "
- "the django test database. The *transaction* argument marks will "
+ "the Django test database. The *transaction* argument marks will "
"allow you to use real transactions in the test like Django's "
"TransactionTestCase.",
)
early_config.addinivalue_line(
"markers",
"urls(modstr): Use a different URLconf for this test, similar to "
- "the `urls` attribute of Django `TestCase` objects. *modstr* is "
+ "the `urls` attribute of Django's `TestCase` objects. *modstr* is "
"a string specifying the module of a URL config, e.g. "
'"my_app.test_urls".',
)
@@ -425,6 +425,30 @@
_disable_class_methods(item.cls)
+def pytest_collection_modifyitems(session, config, items):
+ def get_order_number(test):
+ marker_db = test.get_closest_marker('django_db')
+ if marker_db:
+ transaction = validate_django_db(marker_db)[0]
+ if transaction is True:
+ return 1
+ else:
+ transaction = None
+
+ fixtures = getattr(test, 'funcargnames', [])
+ if "transactional_db" in fixtures:
+ return 1
+
+ if transaction is False:
+ return 0
+ if "db" in fixtures:
+ return 0
+
+ return 2
+
+ items[:] = sorted(items, key=get_order_number)
+
+
@pytest.fixture(autouse=True, scope="session")
def django_test_environment(request):
"""
@@ -488,43 +512,42 @@
@pytest.fixture(autouse=True, scope="class")
def _django_setup_unittest(request, django_db_blocker):
"""Setup a django unittest, internal to pytest-django."""
- if django_settings_is_configured() and is_django_unittest(request):
- request.getfixturevalue("django_test_environment")
- request.getfixturevalue("django_db_setup")
-
- django_db_blocker.unblock()
-
- cls = request.node.cls
-
- # implement missing (as of 1.10) debug() method for django's TestCase
- # see pytest-dev/pytest-django#406
- def _cleaning_debug(self):
- testMethod = getattr(self, self._testMethodName)
- skipped = getattr(self.__class__, "__unittest_skip__", False) or
getattr(
- testMethod, "__unittest_skip__", False
- )
-
- if not skipped:
- self._pre_setup()
- super(cls, self).debug()
- if not skipped:
- self._post_teardown()
+ if not django_settings_is_configured() or not is_django_unittest(request):
+ yield
+ return
+
+ request.getfixturevalue("django_db_setup")
- cls.debug = _cleaning_debug
+ cls = request.node.cls
+
+ # implement missing (as of 1.10) debug() method for django's TestCase
+ # see pytest-dev/pytest-django#406
+ def _cleaning_debug(self):
+ testMethod = getattr(self, self._testMethodName)
+ skipped = getattr(self.__class__, "__unittest_skip__", False) or
getattr(
+ testMethod, "__unittest_skip__", False
+ )
+ if not skipped:
+ self._pre_setup()
+ super(cls, self).debug()
+ if not skipped:
+ self._post_teardown()
+
+ cls.debug = _cleaning_debug
+
+ with django_db_blocker.unblock():
if _handle_unittest_methods:
_restore_class_methods(cls)
cls.setUpClass()
_disable_class_methods(cls)
- def teardown():
- _restore_class_methods(cls)
- cls.tearDownClass()
- django_db_blocker.restore()
+ yield
- request.addfinalizer(teardown)
+ _restore_class_methods(cls)
+ cls.tearDownClass()
else:
- request.addfinalizer(django_db_blocker.restore)
+ yield
@pytest.fixture(scope="function", autouse=True)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-django-3.4.8/pytest_django.egg-info/PKG-INFO
new/pytest-django-3.5.0/pytest_django.egg-info/PKG-INFO
--- old/pytest-django-3.4.8/pytest_django.egg-info/PKG-INFO 2019-02-26
16:03:07.000000000 +0100
+++ new/pytest-django-3.5.0/pytest_django.egg-info/PKG-INFO 2019-06-03
16:24:46.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: pytest-django
-Version: 3.4.8
+Version: 3.5.0
Summary: A Django plugin for pytest.
Home-page: https://pytest-django.readthedocs.io/
Author: Andreas Pelme
@@ -95,5 +95,5 @@
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
-Provides-Extra: docs
Provides-Extra: testing
+Provides-Extra: docs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-django-3.4.8/pytest_django_test/app/models.py
new/pytest-django-3.5.0/pytest_django_test/app/models.py
--- old/pytest-django-3.4.8/pytest_django_test/app/models.py 2019-02-26
16:02:52.000000000 +0100
+++ new/pytest-django-3.5.0/pytest_django_test/app/models.py 2019-06-03
16:24:31.000000000 +0200
@@ -3,9 +3,3 @@
class Item(models.Model):
name = models.CharField(max_length=100)
-
- def __unicode__(self):
- return self.name
-
- def __str__(self):
- return self.name
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-django-3.4.8/pytest_django_test/app/views.py
new/pytest-django-3.5.0/pytest_django_test/app/views.py
--- old/pytest-django-3.4.8/pytest_django_test/app/views.py 2019-02-26
16:02:52.000000000 +0100
+++ new/pytest-django-3.5.0/pytest_django_test/app/views.py 2019-06-03
16:24:31.000000000 +0200
@@ -6,9 +6,8 @@
def admin_required_view(request):
- if request.user.is_staff:
- return HttpResponse(Template("You are an admin").render(Context()))
- return HttpResponse(Template("Access denied").render(Context()))
+ assert request.user.is_staff
+ return HttpResponse(Template("You are an admin").render(Context()))
def item_count(request):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-django-3.4.8/pytest_django_test/db_helpers.py
new/pytest-django-3.5.0/pytest_django_test/db_helpers.py
--- old/pytest-django-3.4.8/pytest_django_test/db_helpers.py 2019-02-26
16:02:52.000000000 +0100
+++ new/pytest-django-3.5.0/pytest_django_test/db_helpers.py 2019-06-03
16:24:31.000000000 +0200
@@ -47,7 +47,7 @@
def run_mysql(*args):
user = _settings.get("USER", None)
- if user:
+ if user: # pragma: no branch
args = ("-u", user) + tuple(args)
args = ("mysql",) + tuple(args)
return run_cmd(*args)
@@ -61,110 +61,97 @@
pytest.skip("Do not test db reuse since database does not support it")
-def drop_database(name=TEST_DB_NAME, suffix=None):
- assert bool(name) ^ bool(suffix), "name and suffix cannot be used together"
+def drop_database(name=TEST_DB_NAME):
+ db_engine = get_db_engine()
- if suffix:
- name = "%s_%s" % (name, suffix)
-
- if get_db_engine() == "postgresql_psycopg2":
+ if db_engine == "postgresql_psycopg2":
r = run_cmd("psql", "postgres", "-c", "DROP DATABASE %s" % name)
assert "DROP DATABASE" in force_text(
r.std_out
) or "does not exist" in force_text(r.std_err)
return
- if get_db_engine() == "mysql":
+ if db_engine == "mysql":
r = run_mysql("-e", "DROP DATABASE %s" % name)
assert "database doesn't exist" in force_text(r.std_err) or
r.status_code == 0
return
- if get_db_engine() == "sqlite3":
- if name == ":memory:":
- raise AssertionError("sqlite in-memory database cannot be
dropped!")
- if os.path.exists(name):
- os.unlink(name)
- return
-
- raise AssertionError("%s cannot be tested properly!" % get_db_engine())
+ assert db_engine == "sqlite3", "%s cannot be tested properly!" % db_engine
+ assert name != ":memory:", "sqlite in-memory database cannot be dropped!"
+ if os.path.exists(name): # pragma: no branch
+ os.unlink(name)
def db_exists(db_suffix=None):
name = TEST_DB_NAME
+ db_engine = get_db_engine()
if db_suffix:
name = "%s_%s" % (name, db_suffix)
- if get_db_engine() == "postgresql_psycopg2":
+ if db_engine == "postgresql_psycopg2":
r = run_cmd("psql", name, "-c", "SELECT 1")
return r.status_code == 0
- if get_db_engine() == "mysql":
+ if db_engine == "mysql":
r = run_mysql(name, "-e", "SELECT 1")
return r.status_code == 0
- if get_db_engine() == "sqlite3":
- if TEST_DB_NAME == ":memory:":
- raise AssertionError(
- "sqlite in-memory database cannot be checked for existence!"
- )
- return os.path.exists(name)
-
- raise AssertionError("%s cannot be tested properly!" % get_db_engine())
+ assert db_engine == "sqlite3", "%s cannot be tested properly!" % db_engine
+ assert TEST_DB_NAME != ":memory:", (
+ "sqlite in-memory database cannot be checked for existence!")
+ return os.path.exists(name)
def mark_database():
- if get_db_engine() == "postgresql_psycopg2":
+ db_engine = get_db_engine()
+
+ if db_engine == "postgresql_psycopg2":
r = run_cmd("psql", TEST_DB_NAME, "-c", "CREATE TABLE mark_table();")
assert r.status_code == 0
return
- if get_db_engine() == "mysql":
+ if db_engine == "mysql":
r = run_mysql(TEST_DB_NAME, "-e", "CREATE TABLE mark_table(kaka int);")
assert r.status_code == 0
return
- if get_db_engine() == "sqlite3":
- if TEST_DB_NAME == ":memory:":
- raise AssertionError("sqlite in-memory database cannot be marked!")
-
- conn = sqlite3.connect(TEST_DB_NAME)
- try:
- with conn:
- conn.execute("CREATE TABLE mark_table(kaka int);")
- finally: # Close the DB even if an error is raised
- conn.close()
- return
-
- raise AssertionError("%s cannot be tested properly!" % get_db_engine())
+ assert db_engine == "sqlite3", "%s cannot be tested properly!" % db_engine
+ assert TEST_DB_NAME != ":memory:", (
+ "sqlite in-memory database cannot be marked!")
+
+ conn = sqlite3.connect(TEST_DB_NAME)
+ try:
+ with conn:
+ conn.execute("CREATE TABLE mark_table(kaka int);")
+ finally: # Close the DB even if an error is raised
+ conn.close()
def mark_exists():
- if get_db_engine() == "postgresql_psycopg2":
+ db_engine = get_db_engine()
+
+ if db_engine == "postgresql_psycopg2":
r = run_cmd("psql", TEST_DB_NAME, "-c", "SELECT 1 FROM mark_table")
# When something pops out on std_out, we are good
return bool(r.std_out)
- if get_db_engine() == "mysql":
+ if db_engine == "mysql":
r = run_mysql(TEST_DB_NAME, "-e", "SELECT 1 FROM mark_table")
return r.status_code == 0
- if get_db_engine() == "sqlite3":
- if TEST_DB_NAME == ":memory:":
- raise AssertionError(
- "sqlite in-memory database cannot be checked for mark!"
- )
-
- conn = sqlite3.connect(TEST_DB_NAME)
- try:
- with conn:
- conn.execute("SELECT 1 FROM mark_table")
- return True
- except sqlite3.OperationalError:
- return False
- finally: # Close the DB even if an error is raised
- conn.close()
-
- raise AssertionError("%s cannot be tested properly!" % get_db_engine())
+ assert db_engine == "sqlite3", "%s cannot be tested properly!" % db_engine
+ assert TEST_DB_NAME != ":memory:", (
+ "sqlite in-memory database cannot be checked for mark!")
+
+ conn = sqlite3.connect(TEST_DB_NAME)
+ try:
+ with conn:
+ conn.execute("SELECT 1 FROM mark_table")
+ return True
+ except sqlite3.OperationalError:
+ return False
+ finally: # Close the DB even if an error is raised
+ conn.close()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pytest-django-3.4.8/pytest_django_test/settings_base.py
new/pytest-django-3.5.0/pytest_django_test/settings_base.py
--- old/pytest-django-3.4.8/pytest_django_test/settings_base.py 2019-02-26
16:02:52.000000000 +0100
+++ new/pytest-django-3.5.0/pytest_django_test/settings_base.py 2019-06-03
16:24:31.000000000 +0200
@@ -16,12 +16,7 @@
# Used to construct unique test database names to allow detox to run multiple
# versions at the same time
-uid = os.getenv("UID", "")
-
-if uid:
- db_suffix = "_%s" % uid
-else:
- db_suffix = ""
+db_suffix = "_%s" % os.getuid()
MIDDLEWARE = [
"django.contrib.sessions.middleware.SessionMiddleware",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-django-3.4.8/tests/conftest.py
new/pytest-django-3.5.0/tests/conftest.py
--- old/pytest-django-3.4.8/tests/conftest.py 2019-02-26 16:02:52.000000000
+0100
+++ new/pytest-django-3.5.0/tests/conftest.py 2019-06-03 16:24:31.000000000
+0200
@@ -6,8 +6,6 @@
import six
from django.conf import settings
-from pytest_django_test.db_helpers import DB_NAME, TEST_DB_NAME
-
try:
import pathlib
except ImportError:
@@ -40,6 +38,8 @@
@pytest.fixture(scope="function")
def django_testdir(request, testdir, monkeypatch):
+ from pytest_django_test.db_helpers import DB_NAME, TEST_DB_NAME
+
marker = request.node.get_closest_marker("django_project")
options = _marker_apifun(**(marker.kwargs if marker else {}))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-django-3.4.8/tests/test_db_setup.py
new/pytest-django-3.5.0/tests/test_db_setup.py
--- old/pytest-django-3.4.8/tests/test_db_setup.py 2019-02-26
16:02:52.000000000 +0100
+++ new/pytest-django-3.5.0/tests/test_db_setup.py 2019-06-03
16:24:31.000000000 +0200
@@ -29,6 +29,38 @@
result.stdout.fnmatch_lines(["*test_db_can_be_accessed PASSED*"])
+def test_db_order(django_testdir):
+ """Test order in which tests are being executed."""
+
+ django_testdir.create_test_module('''
+ import pytest
+
+ from .app.models import Item
+
+ @pytest.mark.django_db(transaction=True)
+ def test_run_second_decorator():
+ pass
+
+ def test_run_second_fixture(transactional_db):
+ pass
+
+ def test_run_first_fixture(db):
+ pass
+
+ @pytest.mark.django_db
+ def test_run_first_decorator():
+ pass
+ ''')
+ result = django_testdir.runpytest_subprocess('-v', '-s')
+ assert result.ret == 0
+ result.stdout.fnmatch_lines([
+ "*test_run_first_fixture*",
+ "*test_run_first_decorator*",
+ "*test_run_second_decorator*",
+ "*test_run_second_fixture*",
+ ])
+
+
def test_db_reuse(django_testdir):
"""
Test the re-use db functionality.
@@ -246,7 +278,13 @@
assert conn_default.vendor == 'sqlite'
db_name = conn_default.creation._get_test_db_name()
- assert 'file:memorydb' in db_name
+
+ # can_share_in_memory_db was removed in Django 2.1, and
+ # used in _get_test_db_name before.
+ if getattr(conn_default.features, "can_share_in_memory_db",
True):
+ assert 'file:memorydb' in db_name
+ else:
+ assert db_name == ":memory:"
assert conn_db2.vendor == 'sqlite'
db_name = conn_db2.creation._get_test_db_name()
@@ -262,7 +300,7 @@
@pytest.mark.skipif(
get_django_version() >= (1, 9),
reason=(
- "Django 1.9 requires migration and has no concept " "of initial data
fixtures"
+ "Django 1.9 requires migration and has no concept of initial data
fixtures"
),
)
def test_initial_data(django_testdir_initial):
@@ -295,7 +333,8 @@
@pytest.mark.django_db
def test_inner_migrations():
- pass
+ from .app.models import Item
+ Item.objects.create()
"""
)
@@ -308,10 +347,11 @@
)
result = django_testdir.runpytest_subprocess(
- "--nomigrations", "--tb=short", "-v"
+ "--nomigrations", "--tb=short", "-vv", "-s",
)
assert result.ret == 0
- result.stdout.fnmatch_lines(["*test_inner_migrations*PASSED*"])
+ assert "Operations to perform:" not in result.stdout.str()
+ result.stdout.fnmatch_lines(["*= 1 passed in *"])
def test_migrations_run(self, django_testdir):
testdir = django_testdir
@@ -321,7 +361,8 @@
@pytest.mark.django_db
def test_inner_migrations():
- pass
+ from .app.models import Item
+ Item.objects.create()
"""
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pytest-django-3.4.8/tests/test_django_configurations.py
new/pytest-django-3.5.0/tests/test_django_configurations.py
--- old/pytest-django-3.4.8/tests/test_django_configurations.py 2019-02-26
16:02:52.000000000 +0100
+++ new/pytest-django-3.5.0/tests/test_django_configurations.py 2019-06-03
16:24:31.000000000 +0200
@@ -6,16 +6,6 @@
pytest.importorskip("configurations")
-try:
- import configurations.importer
-
- configurations
-except ImportError as e:
- if "LaxOptionParser" in e.args[0]:
- pytest.skip(
- "This version of django-configurations is incompatible with
Django: " # noqa
- "https://github.com/jezdez/django-configurations/issues/65"
- ) # noqa
BARE_SETTINGS = """
from configurations import Configuration
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-django-3.4.8/tests/test_fixtures.py
new/pytest-django-3.5.0/tests/test_fixtures.py
--- old/pytest-django-3.4.8/tests/test_fixtures.py 2019-02-26
16:02:52.000000000 +0100
+++ new/pytest-django-3.5.0/tests/test_fixtures.py 2019-06-03
16:24:31.000000000 +0200
@@ -522,11 +522,8 @@
def admin_required_view(request):
- if request.user.is_staff:
- return HttpResponse(
- Template('You are an admin').render(Context()))
- return HttpResponse(
- Template('Access denied').render(Context()))
+ assert request.user.is_staff
+ return HttpResponse(Template('You are an admin').render(Context()))
""",
"views.py",
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-django-3.4.8/tox.ini
new/pytest-django-3.5.0/tox.ini
--- old/pytest-django-3.4.8/tox.ini 2019-02-26 16:02:52.000000000 +0100
+++ new/pytest-django-3.5.0/tox.ini 2019-06-03 16:24:31.000000000 +0200
@@ -19,8 +19,8 @@
dj19: Django>=1.9,<1.10
dj18: Django>=1.8,<1.9
- mysql_myisam: mysql-python==1.2.5
- mysql_innodb: mysql-python==1.2.5
+ mysql_myisam: mysqlclient==1.4.2.post1
+ mysql_innodb: mysqlclient==1.4.2.post1
postgres: psycopg2-binary
coverage: coverage-enable-subprocess