Skip to content
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

python312Packages.pytest-django: run all tests #333933

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkgs/development/python-modules/django-redis/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ buildPythonPackage rec {
"test_delete_pattern_calls_scan_iter_with_count_if_itersize_given"
];

__darwinAllowLocalNetworking = true;

meta = with lib; {
description = "Full featured redis cache backend for Django";
homepage = "https://github.com/jazzband/django-redis";
Expand Down
9 changes: 6 additions & 3 deletions pkgs/development/python-modules/pytest-django/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
setuptools-scm,
django-configurations,
pytest,
pytest-xdist,
pytestCheckHook,
}:
buildPythonPackage rec {
Expand All @@ -19,17 +20,18 @@ buildPythonPackage rec {
hash = "sha256-XQVP4BHFbzsQ+Xj0Go77Llrfx+aA7zb7VxraHyR3nZA=";
};

nativeBuildInputs = [
build-system = [
setuptools
setuptools-scm
];

buildInputs = [ pytest ];

propagatedBuildInputs = [ django ];
dependencies = [ django ];

nativeCheckInputs = [
django-configurations
pytest-xdist
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we exposed some racy tests here: I tried building it multiple times and every time some other tests have failed:

#336569

=================================== FAILURES ===================================
_________________ Test_django_db_blocker.test_unblock_manually _________________
[gw87] linux -- Python 3.12.4 /nix/store/04gg5w1s662l329a8kh9xcwyp0k64v5a-python3-3.12.4/bin/python3.12

self = <django.db.backends.utils.CursorWrapper object at 0x7ffff4a9a3f0>
sql = 'SELECT %s AS "a" FROM "app_item" LIMIT 1', params = (1,)
ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='sqlite' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7ffff4a9a3f0>})

    def _execute(self, sql, params, *ignored_wrapper_args):
        self.db.validate_no_broken_transaction()
        with self.db.wrap_database_errors:
            if params is None:
                # params default might be backend specific.
                return self.cursor.execute(sql)
            else:
>               return self.cursor.execute(sql, params)

/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/backends/utils.py:89: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <django.db.backends.sqlite3.base.SQLiteCursorWrapper object at 0x7ffff47ad6d0>
query = 'SELECT ? AS "a" FROM "app_item" LIMIT 1', params = (1,)

    def execute(self, query, params=None):
        if params is None:
            return super().execute(query)
        # Extract names if params is a mapping, i.e. "pyformat" style is used.
        param_names = list(params) if isinstance(params, Mapping) else None
        query = self.convert_query(query, param_names=param_names)
>       return super().execute(query, params)
E       sqlite3.OperationalError: no such table: app_item

/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py:328: OperationalError

The above exception was the direct cause of the following exception:

self = <tests.test_fixtures.Test_django_db_blocker object at 0x7ffff477e3c0>
django_db_blocker = <pytest_django.plugin.DjangoDbBlocker object at 0x7ffff5cd7d10>

    def test_unblock_manually(self, django_db_blocker: DjangoDbBlocker) -> None:
        try:
            django_db_blocker.unblock()
>           Item.objects.exists()

tests/test_fixtures.py:719: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/models/query.py:1241: in exists
    return self.query.has_results(using=self.db)
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/models/sql/query.py:598: in has_results
    return compiler.has_results()
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/models/sql/compiler.py:1530: in has_results
    return bool(self.execute_sql(SINGLE))
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/models/sql/compiler.py:1562: in execute_sql
    cursor.execute(sql, params)
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/backends/utils.py:67: in execute
    return self._execute_with_wrappers(
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/backends/utils.py:80: in _execute_with_wrappers
    return executor(sql, params, many, context)
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/backends/utils.py:84: in _execute
    with self.db.wrap_database_errors:
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/backends/utils.py:89: in _execute
    return self.cursor.execute(sql, params)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <django.db.backends.sqlite3.base.SQLiteCursorWrapper object at 0x7ffff47ad6d0>
query = 'SELECT ? AS "a" FROM "app_item" LIMIT 1', params = (1,)

    def execute(self, query, params=None):
        if params is None:
            return super().execute(query)
        # Extract names if params is a mapping, i.e. "pyformat" style is used.
        param_names = list(params) if isinstance(params, Mapping) else None
        query = self.convert_query(query, param_names=param_names)
>       return super().execute(query, params)
E       django.db.utils.OperationalError: no such table: app_item

/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py:328: OperationalError
________________ Test_django_db_blocker.test_unblock_with_block ________________
[gw87] linux -- Python 3.12.4 /nix/store/04gg5w1s662l329a8kh9xcwyp0k64v5a-python3-3.12.4/bin/python3.12

self = <django.db.backends.utils.CursorWrapper object at 0x7ffff4ac65d0>
sql = 'SELECT %s AS "a" FROM "app_item" LIMIT 1', params = (1,)
ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='sqlite' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7ffff4ac65d0>})

    def _execute(self, sql, params, *ignored_wrapper_args):
        self.db.validate_no_broken_transaction()
        with self.db.wrap_database_errors:
            if params is None:
                # params default might be backend specific.
                return self.cursor.execute(sql)
            else:
>               return self.cursor.execute(sql, params)

/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/backends/utils.py:89: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <django.db.backends.sqlite3.base.SQLiteCursorWrapper object at 0x7ffff461f020>
query = 'SELECT ? AS "a" FROM "app_item" LIMIT 1', params = (1,)

    def execute(self, query, params=None):
        if params is None:
            return super().execute(query)
        # Extract names if params is a mapping, i.e. "pyformat" style is used.
        param_names = list(params) if isinstance(params, Mapping) else None
        query = self.convert_query(query, param_names=param_names)
>       return super().execute(query, params)
E       sqlite3.OperationalError: no such table: app_item

/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py:328: OperationalError

The above exception was the direct cause of the following exception:

self = <tests.test_fixtures.Test_django_db_blocker object at 0x7ffff477e750>
django_db_blocker = <pytest_django.plugin.DjangoDbBlocker object at 0x7ffff5cd7d10>

    def test_unblock_with_block(self, django_db_blocker: DjangoDbBlocker) -> None:
        with django_db_blocker.unblock():
>           Item.objects.exists()

tests/test_fixtures.py:725: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/models/query.py:1241: in exists
    return self.query.has_results(using=self.db)
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/models/sql/query.py:598: in has_results
    return compiler.has_results()
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/models/sql/compiler.py:1530: in has_results
    return bool(self.execute_sql(SINGLE))
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/models/sql/compiler.py:1562: in execute_sql
    cursor.execute(sql, params)
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/backends/utils.py:67: in execute
    return self._execute_with_wrappers(
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/backends/utils.py:80: in _execute_with_wrappers
    return executor(sql, params, many, context)
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/backends/utils.py:84: in _execute
    with self.db.wrap_database_errors:
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/backends/utils.py:89: in _execute
    return self.cursor.execute(sql, params)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <django.db.backends.sqlite3.base.SQLiteCursorWrapper object at 0x7ffff461f020>
query = 'SELECT ? AS "a" FROM "app_item" LIMIT 1', params = (1,)

    def execute(self, query, params=None):
        if params is None:
            return super().execute(query)
        # Extract names if params is a mapping, i.e. "pyformat" style is used.
        param_names = list(params) if isinstance(params, Mapping) else None
        query = self.convert_query(query, param_names=param_names)
>       return super().execute(query, params)
E       django.db.utils.OperationalError: no such table: app_item

/nix/store/d9nnvdisc2d5dvqsgv48niqrp9fxsqx9-python3.12-django-4.2.15/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py:328: OperationalError
=========================== short test summary info ============================
SKIPPED [2] pytest_django_test/db_helpers.py:91: Do not test db reuse since database does not support it
FAILED tests/test_fixtures.py::Test_django_db_blocker::test_unblock_manually - django.db.utils.OperationalError: no such table: app_item
FAILED tests/test_fixtures.py::Test_django_db_blocker::test_unblock_with_block - django.db.utils.OperationalError: no such table: app_item
=================== 2 failed, 213 passed, 2 skipped in 8.05s ===================

pytestCheckHook
];

Expand All @@ -49,7 +51,8 @@ buildPythonPackage rec {
__darwinAllowLocalNetworking = true;

meta = with lib; {
description = "py.test plugin for testing of Django applications";
changelog = "https://github.com/pytest-dev/pytest-django/blob/v${version}/docs/changelog.rst";
description = "Pytest plugin for testing of Django applications";
homepage = "https://pytest-django.readthedocs.org/en/latest/";
license = licenses.bsd3;
};
Expand Down