Skip to content

sqlite tests failed in 3.4.8 under python 2.7 #712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
felixonmars opened this issue Mar 20, 2019 · 9 comments · Fixed by #739
Closed

sqlite tests failed in 3.4.8 under python 2.7 #712

felixonmars opened this issue Mar 20, 2019 · 9 comments · Fixed by #739
Labels

Comments

@felixonmars
Copy link

The failure is not present when running under python 3.7, or with pytest-django 3.4.7 and python 2.7.

=================================== FAILURES ===================================
________ TestSqliteWithMultipleDbsAndXdist.test_sqlite_database_renamed ________

self = <test_db_setup.TestSqliteWithMultipleDbsAndXdist instance at 0x7f49a08c0518>
django_testdir = <Testdir local('/tmp/pytest-of-builduser/pytest-1/test_sqlite_database_renamed0')>

    def test_sqlite_database_renamed(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_db2, conn_default) = sorted(
                    connections.all(),
                    key=lambda conn: conn.alias,
                )

                assert conn_default.vendor == 'sqlite'
                db_name = conn_default.creation._get_test_db_name()
                assert 'file:memorydb' in db_name

                assert conn_db2.vendor == 'sqlite'
                db_name = conn_db2.creation._get_test_db_name()
                assert 'test_custom_db_name_gw' in db_name
        """
        )

        result = django_testdir.runpytest_subprocess("--tb=short", "-vv", "-n1")
>       assert result.ret == 0
E       assert 1 == 0
E        +  where 1 = <RunResult ret=1 len(stdout.lines)=60 len(stderr.lines)=0 duration=2.17s>.ret

/build/python-pytest-django/src/pytest-django-3.4.8-py2/tests/test_db_setup.py:258: AssertionError
----------------------------- Captured stdout call -----------------------------
running: /usr/bin/python2 -mpytest --basetemp=/tmp/pytest-of-builduser/pytest-1/test_sqlite_database_renamed0/runpytest-0 --tb=short -vv -n1
     in: /tmp/pytest-of-builduser/pytest-1/test_sqlite_database_renamed0
============================= test session starts ==============================
platform linux2 -- Python 2.7.16, pytest-4.3.1, py-1.8.0, pluggy-0.9.0 -- /usr/bin/python2
cachedir: .pytest_cache
Django settings: tpkg.the_settings (from environment variable)
rootdir: /tmp/pytest-of-builduser/pytest-1/test_sqlite_database_renamed0, inifile: tox.ini
plugins: django-3.4.8, xdist-1.26.1, forked-1.0.2
gw0 I

[gw0] linux2 Python 2.7.16 cwd: /tmp/pytest-of-builduser/pytest-1/test_sqlite_database_renamed0

[gw0] Python 2.7.16 (default, Mar 11 2019, 18:59:25)  -- [GCC 8.2.1 20181127]
gw0 [1]

scheduling tests via LoadScheduling

tpkg/test_the_test.py::test_a
[gw0] FAILED tpkg/test_the_test.py::test_a

=================================== FAILURES ===================================
____________________________________ test_a ____________________________________
[gw0] linux2 -- Python 2.7.16 /usr/bin/python2
tpkg/test_the_test.py:14: in test_a
    assert 'file:memorydb' in db_name
E   AssertionError: assert 'file:memorydb' in ':memory:'
@blueyed
Copy link
Contributor

blueyed commented May 30, 2019

Likely caused by 8656a22 then.

Confirmed using tox -e py27-dj111-sqlite-xdist -- -k test_sqlite_database_renamed.

/cc @adamantike

@blueyed
Copy link
Contributor

blueyed commented May 30, 2019

@felixonmars
Thanks for the report, should be fixed on master.

@felixonmars
Copy link
Author

Not sure what was different, but the change introduces another error here:

=================================== FAILURES ===================================
____________________________________ test_a ____________________________________
[gw0] linux -- Python 3.7.3 /usr/bin/python
tpkg/test_the_test.py:14: in test_a
    if conn_default.features.can_share_in_memory_db:
E   AttributeError: 'DatabaseFeatures' object has no attribute 'can_share_in_memory_db'
---------------------------- Captured stdout setup -----------------------------
Operations to perform:
  Apply all migrations: app, auth, contenttypes
Running migrations:
  Applying app.0001_initial... OK
  Applying contenttypes.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0001_initial... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
Operations to perform:
  Apply all migrations: app, auth, contenttypes
Running migrations:
  Applying app.0001_initial... OK
  Applying contenttypes.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0001_initial... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
---------------------------- Captured stderr setup -----------------------------
Creating test database for alias 'default' ('file:memorydb_default?mode=memory&cache=shared')...
Creating test database for alias 'db2' ('test_custom_db_name_gw0')...
Destroying old test database for alias 'db2' ('test_custom_db_name_gw0')...
--------------------------- Captured stderr teardown ---------------------------
Destroying test database for alias 'default' ('file:memorydb_default?mode=memory&cache=shared')...
Destroying test database for alias 'db2' ('test_custom_db_name_gw0')...
=========================== 1 failed in 0.93 seconds ===========================

@blueyed
Copy link
Contributor

blueyed commented May 30, 2019

What Django version do you use?
Should be fixed by #741 I guess.

@blueyed
Copy link
Contributor

blueyed commented May 30, 2019

Hope it works now.. :)

@felixonmars
Copy link
Author

Indeed it was fixed now. I am running with Django 2.2.1. Many thanks!

@blueyed
Copy link
Contributor

blueyed commented May 30, 2019

Great! Thanks for the report again.

Do you plan to contribute to pytest-django?

@blueyed
Copy link
Contributor

blueyed commented May 30, 2019

Ah, it's for Arch probably?

@felixonmars
Copy link
Author

Yes, since I am packaging it for Arch.

beyondgeeks pushed a commit to beyondgeeks/django-pytest that referenced this issue Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants