Hello community,

here is the log from the commit of package python-pytest-django for 
openSUSE:Factory checked in at 2019-11-25 11:23:45
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pytest-django (Old)
 and      /work/SRC/openSUSE:Factory/.python-pytest-django.new.26869 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pytest-django"

Mon Nov 25 11:23:45 2019 rev:9 rq:750272 version:3.7.0

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-pytest-django/python-pytest-django.changes    
    2019-11-03 11:39:22.634007607 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-pytest-django.new.26869/python-pytest-django.changes
     2019-11-25 11:23:46.858111345 +0100
@@ -1,0 +2,10 @@
+Fri Nov 15 10:49:15 UTC 2019 - Tomáš Chvátal <tchva...@suse.com>
+
+- Update to 3.7.0:
+  * Monkeypatch pytest to not use ``TestCase.debug`` with unittests, instead
+    of patching it into Django (#782).
+  * Work around pytest crashing due to ``pytest.fail`` being used from within 
the
+    DB blocker, and pytest trying to display an object representation involving
+    DB access (#781).  pytest-django uses a ``RuntimeError`` now instead.
+
+-------------------------------------------------------------------

Old:
----
  pytest-django-3.6.0.tar.gz

New:
----
  pytest-django-3.7.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-pytest-django.spec ++++++
--- /var/tmp/diff_new_pack.WLxdHy/_old  2019-11-25 11:23:47.346111258 +0100
+++ /var/tmp/diff_new_pack.WLxdHy/_new  2019-11-25 11:23:47.350111257 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-pytest-django
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LLC.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-pytest-django
-Version:        3.6.0
+Version:        3.7.0
 Release:        0
 Summary:        A Django plugin for py.test
 License:        BSD-3-Clause

++++++ pytest-django-3.6.0.tar.gz -> pytest-django-3.7.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-django-3.6.0/PKG-INFO 
new/pytest-django-3.7.0/PKG-INFO
--- old/pytest-django-3.6.0/PKG-INFO    2019-10-17 03:07:59.000000000 +0200
+++ new/pytest-django-3.7.0/PKG-INFO    2019-11-09 07:16:53.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: pytest-django
-Version: 3.6.0
+Version: 3.7.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.6.0/docs/changelog.rst 
new/pytest-django-3.7.0/docs/changelog.rst
--- old/pytest-django-3.6.0/docs/changelog.rst  2019-10-17 03:07:43.000000000 
+0200
+++ new/pytest-django-3.7.0/docs/changelog.rst  2019-11-09 07:16:37.000000000 
+0100
@@ -1,6 +1,20 @@
 Changelog
 =========
 
+3.7.0 (2019-11-09)
+------------------
+
+Bugfixes
+^^^^^^^^
+
+* Monkeypatch pytest to not use ``TestCase.debug`` with unittests, instead
+  of patching it into Django (#782).
+
+* Work around pytest crashing due to ``pytest.fail`` being used from within the
+  DB blocker, and pytest trying to display an object representation involving
+  DB access (#781).  pytest-django uses a ``RuntimeError`` now instead.
+
+
 3.6.0 (2019-10-17)
 ------------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pytest-django-3.6.0/pytest_django/live_server_helper.py 
new/pytest-django-3.7.0/pytest_django/live_server_helper.py
--- old/pytest-django-3.6.0/pytest_django/live_server_helper.py 2019-10-17 
03:07:43.000000000 +0200
+++ new/pytest-django-3.7.0/pytest_django/live_server_helper.py 2019-11-09 
07:16:37.000000000 +0100
@@ -1,6 +1,7 @@
-import sys
+import six
 
 
+@six.python_2_unicode_compatible
 class LiveServer(object):
     """The liveserver fixture
 
@@ -70,21 +71,11 @@
     def url(self):
         return "http://%s:%s"; % (self.thread.host, self.thread.port)
 
-    if sys.version_info < (3, 0):
+    def __str__(self):
+        return self.url
 
-        def __unicode__(self):
-            return self.url
-
-        def __add__(self, other):
-            return unicode(self) + other  # noqa: pyflakes on python3
-
-    else:
-
-        def __str__(self):
-            return self.url
-
-        def __add__(self, other):
-            return str(self) + other
+    def __add__(self, other):
+        return "%s%s" % (self, other)
 
     def __repr__(self):
         return "<LiveServer listening at %s>" % self.url
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-django-3.6.0/pytest_django/plugin.py 
new/pytest-django-3.7.0/pytest_django/plugin.py
--- old/pytest-django-3.6.0/pytest_django/plugin.py     2019-10-17 
03:07:43.000000000 +0200
+++ new/pytest-django-3.7.0/pytest_django/plugin.py     2019-11-09 
07:16:37.000000000 +0100
@@ -518,27 +518,24 @@
         yield
         return
 
-    request.getfixturevalue("django_db_setup")
+    from _pytest.unittest import TestCaseFunction
 
-    cls = request.node.cls
+    if "debug" in TestCaseFunction.runtest.__code__.co_names:
+        # Fix pytest (https://github.com/pytest-dev/pytest/issues/5991), only
+        # if "self._testcase.debug()" is being used (forward compatible).
+        from _pytest.monkeypatch import MonkeyPatch
+
+        def non_debugging_runtest(self):
+            self._testcase(result=self)
+
+        mp_debug = MonkeyPatch()
+        mp_debug.setattr("_pytest.unittest.TestCaseFunction.runtest", 
non_debugging_runtest)
+    else:
+        mp_debug = None
 
-    # 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(
-            testMethod, "__unittest_skip__", False
-        )
-
-        if not skipped:
-            self._pre_setup()
-        super(cls, self).debug()
-        if not skipped:
-            self._post_teardown()
+    request.getfixturevalue("django_db_setup")
 
-    orig_debug = cls.debug
-    cls.debug = _cleaning_debug
+    cls = request.node.cls
 
     with django_db_blocker.unblock():
         if _handle_unittest_methods:
@@ -553,7 +550,8 @@
         else:
             yield
 
-    cls.debug = orig_debug
+    if mp_debug:
+        mp_debug.undo()
 
 
 @pytest.fixture(scope="function", autouse=True)
@@ -774,7 +772,7 @@
     def _blocking_wrapper(*args, **kwargs):
         __tracebackhide__ = True
         __tracebackhide__  # Silence pyflakes
-        pytest.fail(
+        raise RuntimeError(
             "Database access not allowed, "
             'use the "django_db" mark, or the '
             '"db" or "transactional_db" fixtures to enable it.'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-django-3.6.0/pytest_django.egg-info/PKG-INFO 
new/pytest-django-3.7.0/pytest_django.egg-info/PKG-INFO
--- old/pytest-django-3.6.0/pytest_django.egg-info/PKG-INFO     2019-10-17 
03:07:59.000000000 +0200
+++ new/pytest-django-3.7.0/pytest_django.egg-info/PKG-INFO     2019-11-09 
07:16:53.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: pytest-django
-Version: 3.6.0
+Version: 3.7.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.6.0/pytest_django.egg-info/SOURCES.txt 
new/pytest-django-3.7.0/pytest_django.egg-info/SOURCES.txt
--- old/pytest-django-3.6.0/pytest_django.egg-info/SOURCES.txt  2019-10-17 
03:07:59.000000000 +0200
+++ new/pytest-django-3.7.0/pytest_django.egg-info/SOURCES.txt  2019-11-09 
07:16:53.000000000 +0100
@@ -59,6 +59,7 @@
 pytest_django_test/app/static/a_file.txt
 tests/conftest.py
 tests/test_database.py
+tests/test_db_access_in_repr.py
 tests/test_db_setup.py
 tests/test_django_configurations.py
 tests/test_django_settings_module.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-django-3.6.0/pytest_django_test/db_helpers.py 
new/pytest-django-3.7.0/pytest_django_test/db_helpers.py
--- old/pytest-django-3.6.0/pytest_django_test/db_helpers.py    2019-10-17 
03:07:43.000000000 +0200
+++ new/pytest-django-3.7.0/pytest_django_test/db_helpers.py    2019-11-09 
07:16:37.000000000 +0100
@@ -5,7 +5,7 @@
 import pytest
 
 from django.conf import settings
-from django.utils.encoding import force_text
+from django.utils.encoding import force_str
 
 
 # Construct names for the "inner" database used in runpytest tests
@@ -66,14 +66,14 @@
 
     if db_engine == "postgresql_psycopg2":
         r = run_cmd("psql", "postgres", "-c", "DROP DATABASE %s" % name)
-        assert "DROP DATABASE" in force_text(
+        assert "DROP DATABASE" in force_str(
             r.std_out
-        ) or "does not exist" in force_text(r.std_err)
+        ) or "does not exist" in force_str(r.std_err)
         return
 
     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
+        assert "database doesn't exist" in force_str(r.std_err) or 
r.status_code == 0
         return
 
     assert db_engine == "sqlite3", "%s cannot be tested properly!" % db_engine
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-django-3.6.0/tests/test_database.py 
new/pytest-django-3.7.0/tests/test_database.py
--- old/pytest-django-3.6.0/tests/test_database.py      2019-10-17 
03:07:43.000000000 +0200
+++ new/pytest-django-3.7.0/tests/test_database.py      2019-11-09 
07:16:37.000000000 +0100
@@ -16,17 +16,17 @@
 
 
 def test_noaccess():
-    with pytest.raises(pytest.fail.Exception):
+    with pytest.raises(RuntimeError):
         Item.objects.create(name="spam")
-    with pytest.raises(pytest.fail.Exception):
+    with pytest.raises(RuntimeError):
         Item.objects.count()
 
 
 @pytest.fixture
 def noaccess():
-    with pytest.raises(pytest.fail.Exception):
+    with pytest.raises(RuntimeError):
         Item.objects.create(name="spam")
-    with pytest.raises(pytest.fail.Exception):
+    with pytest.raises(RuntimeError):
         Item.objects.count()
 
 
@@ -254,7 +254,7 @@
             "*test_db_access_2 FAILED*",
             "*test_db_access_3 FAILED*",
             "*ERROR at setup of TestCase_setupClass.test_db_access_1*",
-            '*Failed: Database access not allowed, use the "django_db" mark, '
+            '*RuntimeError: Database access not allowed, use the "django_db" 
mark, '
             'or the "db" or "transactional_db" fixtures to enable it.',
         ]
     )
@@ -274,7 +274,7 @@
         result = django_testdir.runpytest_subprocess("-v")
         result.stderr.fnmatch_lines(
             [
-                '*Failed: Database access not allowed, use the "django_db" 
mark, '
+                '*RuntimeError: Database access not allowed, use the 
"django_db" mark, '
                 'or the "db" or "transactional_db" fixtures to enable it.*'
             ]
         )
@@ -290,7 +290,7 @@
         result = django_testdir.runpytest_subprocess("-v")
         result.stdout.fnmatch_lines(
             [
-                '*Failed: Database access not allowed, use the "django_db" 
mark, '
+                '*RuntimeError: Database access not allowed, use the 
"django_db" mark, '
                 'or the "db" or "transactional_db" fixtures to enable it.'
             ]
         )
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-django-3.6.0/tests/test_db_access_in_repr.py 
new/pytest-django-3.7.0/tests/test_db_access_in_repr.py
--- old/pytest-django-3.6.0/tests/test_db_access_in_repr.py     1970-01-01 
01:00:00.000000000 +0100
+++ new/pytest-django-3.7.0/tests/test_db_access_in_repr.py     2019-11-09 
07:16:37.000000000 +0100
@@ -0,0 +1,27 @@
+def test_db_access_with_repr_in_report(django_testdir):
+    django_testdir.create_test_module(
+        """
+        import pytest
+
+        from .app.models import Item
+
+        def test_via_db_blocker(django_db_setup, django_db_blocker):
+            with django_db_blocker.unblock():
+                Item.objects.get(name='This one is not there')
+
+        def test_via_db_fixture(db):
+            Item.objects.get(name='This one is not there')
+    """
+    )
+
+    result = django_testdir.runpytest_subprocess("--tb=auto")
+    result.stdout.fnmatch_lines([
+        "tpkg/test_the_test.py FF",
+        "E   *DoesNotExist: Item matching query does not exist.",
+        "tpkg/test_the_test.py:8: ",
+        'self = *RuntimeError*Database access not allowed*',
+        "E   *DoesNotExist: Item matching query does not exist.",
+        "* 2 failed in *",
+    ])
+    assert "INTERNALERROR" not in str(result.stdout) + str(result.stderr)
+    assert result.ret == 1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-django-3.6.0/tests/test_environment.py 
new/pytest-django-3.7.0/tests/test_environment.py
--- old/pytest-django-3.6.0/tests/test_environment.py   2019-10-17 
03:07:43.000000000 +0200
+++ new/pytest-django-3.7.0/tests/test_environment.py   2019-11-09 
07:16:37.000000000 +0100
@@ -219,7 +219,7 @@
 
 
 def test_database_noaccess():
-    with pytest.raises(pytest.fail.Exception):
+    with pytest.raises(RuntimeError):
         Item.objects.count()
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-django-3.6.0/tests/test_fixtures.py 
new/pytest-django-3.7.0/tests/test_fixtures.py
--- old/pytest-django-3.6.0/tests/test_fixtures.py      2019-10-17 
03:07:43.000000000 +0200
+++ new/pytest-django-3.7.0/tests/test_fixtures.py      2019-11-09 
07:16:37.000000000 +0100
@@ -15,7 +15,7 @@
 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
+from django.utils.encoding import force_str
 
 from pytest_django.lazy_django import get_django_version
 from pytest_django_test.app.models import Item
@@ -42,13 +42,13 @@
 def test_admin_client(admin_client):
     assert isinstance(admin_client, 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"
 
 
 def test_admin_client_no_db_marker(admin_client):
     assert isinstance(admin_client, 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"
 
 
 @pytest.mark.django_db
@@ -328,10 +328,10 @@
         TestLiveServer._test_settings_before_run = True
 
     def test_url(self, live_server):
-        assert live_server.url == force_text(live_server)
+        assert live_server.url == force_str(live_server)
 
     def test_change_settings(self, live_server, settings):
-        assert live_server.url == force_text(live_server)
+        assert live_server.url == force_str(live_server)
 
     def test_settings_restored(self):
         """Ensure that settings are restored after test_settings_before."""
@@ -356,20 +356,20 @@
 
     def test_db_changes_visibility(self, live_server):
         response_data = urlopen(live_server + "/item_count/").read()
-        assert force_text(response_data) == "Item count: 0"
+        assert force_str(response_data) == "Item count: 0"
         Item.objects.create(name="foo")
         response_data = urlopen(live_server + "/item_count/").read()
-        assert force_text(response_data) == "Item count: 1"
+        assert force_str(response_data) == "Item count: 1"
 
     def test_fixture_db(self, db, live_server):
         Item.objects.create(name="foo")
         response_data = urlopen(live_server + "/item_count/").read()
-        assert force_text(response_data) == "Item count: 1"
+        assert force_str(response_data) == "Item count: 1"
 
     def test_fixture_transactional_db(self, transactional_db, live_server):
         Item.objects.create(name="foo")
         response_data = urlopen(live_server + "/item_count/").read()
-        assert force_text(response_data) == "Item count: 1"
+        assert force_str(response_data) == "Item count: 1"
 
     @pytest.fixture
     def item(self):
@@ -386,7 +386,7 @@
 
     def test_item_db(self, item_db, live_server):
         response_data = urlopen(live_server + "/item_count/").read()
-        assert force_text(response_data) == "Item count: 1"
+        assert force_str(response_data) == "Item count: 1"
 
     @pytest.fixture
     def item_transactional_db(self, transactional_db):
@@ -394,7 +394,7 @@
 
     def test_item_transactional_db(self, item_transactional_db, live_server):
         response_data = urlopen(live_server + "/item_count/").read()
-        assert force_text(response_data) == "Item count: 1"
+        assert force_str(response_data) == "Item count: 1"
 
     @pytest.mark.django_project(
         extra_settings="""
@@ -418,7 +418,7 @@
         django_testdir.create_test_module(
             """
             import pytest
-            from django.utils.encoding import force_text
+            from django.utils.encoding import force_str
 
             try:
                 from urllib2 import urlopen, HTTPError
@@ -431,7 +431,7 @@
                             in settings.INSTALLED_APPS)
                     response_data = urlopen(
                         live_server + '/static/a_file.txt').read()
-                    assert force_text(response_data) == 'bla\\n'
+                    assert force_str(response_data) == 'bla\\n'
             """
         )
         result = django_testdir.runpytest_subprocess("--tb=short", "-v")
@@ -607,7 +607,7 @@
     def test_block_manually(self, django_db_blocker):
         try:
             django_db_blocker.block()
-            with pytest.raises(pytest.fail.Exception):
+            with pytest.raises(RuntimeError):
                 Item.objects.exists()
         finally:
             django_db_blocker.restore()
@@ -615,7 +615,7 @@
     @pytest.mark.django_db
     def test_block_with_block(self, django_db_blocker):
         with django_db_blocker.block():
-            with pytest.raises(pytest.fail.Exception):
+            with pytest.raises(RuntimeError):
                 Item.objects.exists()
 
     def test_unblock_manually(self, django_db_blocker):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-django-3.6.0/tests/test_unittest.py 
new/pytest-django-3.7.0/tests/test_unittest.py
--- old/pytest-django-3.6.0/tests/test_unittest.py      2019-10-17 
03:07:43.000000000 +0200
+++ new/pytest-django-3.7.0/tests/test_unittest.py      2019-11-09 
07:16:37.000000000 +0100
@@ -458,7 +458,7 @@
     assert result.ret == 0
 
 
-def test_debug_restored(django_testdir):
+def test_debug_not_used(django_testdir):
     django_testdir.create_test_module(
         """
         from django.test import TestCase
@@ -468,22 +468,14 @@
 
         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 debug(self):
+                assert 0, "should not be called"
 
             def test_method(self):
-                assert pre_setup_count == 1
+                pass
     """
     )
 
     result = django_testdir.runpytest_subprocess("--pdb")
-    result.stdout.fnmatch_lines(["*= 2 passed in *"])
+    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.6.0/tests/test_urls.py 
new/pytest-django-3.7.0/tests/test_urls.py
--- old/pytest-django-3.6.0/tests/test_urls.py  2019-10-17 03:07:43.000000000 
+0200
+++ new/pytest-django-3.7.0/tests/test_urls.py  2019-11-09 07:16:37.000000000 
+0100
@@ -1,6 +1,6 @@
 import pytest
 from django.conf import settings
-from django.utils.encoding import force_text
+from django.utils.encoding import force_str
 
 
 @pytest.mark.urls("pytest_django_test.urls_overridden")
@@ -16,7 +16,7 @@
 @pytest.mark.urls("pytest_django_test.urls_overridden")
 def test_urls_client(client):
     response = client.get("/overridden_url/")
-    assert force_text(response.content) == "Overridden urlconf works!"
+    assert force_str(response.content) == "Overridden urlconf works!"
 
 
 def test_urls_cache_is_cleared(testdir):


Reply via email to