Repository: django-import-export/django-import-export (branch: release-4)
Commit date: 2023-12-05T16:44:56Z

Workflow file: .github/workflows/pre-commit.yml (.github/workflows/pre-commit.yml)
on:
  pull_request:
  push:
    branches:
      - main

jobs:
  main:
    runs-on: ubuntu-latest
    services:
      pypi_wayback:
        image: ghcr.io/waleko/pypi-wayback
        ports:
          - 8629:8080
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-python@v4
      with:
        python-version: 3.x
    - uses: pre-commit/action@v3.0.0
    - uses: pre-commit-ci/lite-action@v1.0.1
      if: always()

env:
  PIP_INDEX_URL: http://localhost:8629/2023-12-05
  UV_INDEX_URL: http://localhost:8629/2023-12-05


Failed build logs:
step_name: main/4_Run pre-commitaction@v3.0.0.txt
log: ##[group]Run pre-commit/action@v3.0.0
with:
  extra_args: --all-files
env:
  pythonLocation: /opt/hostedtoolcache/Python/3.12.0/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.12.0/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.0/x64/lib
##[endgroup]
##[group]Run python -m pip install pre-commit
[36;1mpython -m pip install pre-commit[0m
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  pythonLocation: /opt/hostedtoolcache/Python/3.12.0/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.12.0/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.0/x64/lib
##[endgroup]
Collecting pre-commit
  Downloading pre_commit-3.5.0-py2.py3-none-any.whl.metadata (1.3 kB)
Collecting cfgv>=2.0.0 (from pre-commit)
  Downloading cfgv-3.4.0-py2.py3-none-any.whl.metadata (8.5 kB)
Collecting identify>=1.0.0 (from pre-commit)
  Downloading identify-2.5.32-py2.py3-none-any.whl.metadata (4.4 kB)
Collecting nodeenv>=0.11.1 (from pre-commit)
  Downloading nodeenv-1.8.0-py2.py3-none-any.whl.metadata (21 kB)
Collecting pyyaml>=5.1 (from pre-commit)
  Downloading PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.1 kB)
Collecting virtualenv>=20.10.0 (from pre-commit)
  Downloading virtualenv-20.25.0-py3-none-any.whl.metadata (4.5 kB)
Collecting setuptools (from nodeenv>=0.11.1->pre-commit)
  Downloading setuptools-69.0.2-py3-none-any.whl.metadata (6.3 kB)
Collecting distlib<1,>=0.3.7 (from virtualenv>=20.10.0->pre-commit)
  Downloading distlib-0.3.7-py2.py3-none-any.whl.metadata (5.1 kB)
Collecting filelock<4,>=3.12.2 (from virtualenv>=20.10.0->pre-commit)
  Downloading filelock-3.13.1-py3-none-any.whl.metadata (2.8 kB)
Collecting platformdirs<5,>=3.9.1 (from virtualenv>=20.10.0->pre-commit)
  Downloading platformdirs-4.1.0-py3-none-any.whl.metadata (11 kB)
Downloading pre_commit-3.5.0-py2.py3-none-any.whl (203 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 203.7/203.7 kB 15.5 MB/s eta 0:00:00
Downloading cfgv-3.4.0-py2.py3-none-any.whl (7.2 kB)
Downloading identify-2.5.32-py2.py3-none-any.whl (98 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.9/98.9 kB 31.4 MB/s eta 0:00:00
Downloading nodeenv-1.8.0-py2.py3-none-any.whl (22 kB)
Downloading PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (724 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 725.0/725.0 kB 64.9 MB/s eta 0:00:00
Downloading virtualenv-20.25.0-py3-none-any.whl (3.8 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.8/3.8 MB 117.0 MB/s eta 0:00:00
Downloading distlib-0.3.7-py2.py3-none-any.whl (468 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.9/468.9 kB 83.6 MB/s eta 0:00:00
Downloading filelock-3.13.1-py3-none-any.whl (11 kB)
Downloading platformdirs-4.1.0-py3-none-any.whl (17 kB)
Downloading setuptools-69.0.2-py3-none-any.whl (819 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 819.5/819.5 kB 98.1 MB/s eta 0:00:00
Installing collected packages: distlib, setuptools, pyyaml, platformdirs, identify, filelock, cfgv, virtualenv, nodeenv, pre-commit
Successfully installed cfgv-3.4.0 distlib-0.3.7 filelock-3.13.1 identify-2.5.32 nodeenv-1.8.0 platformdirs-4.1.0 pre-commit-3.5.0 pyyaml-6.0.1 setuptools-69.0.2 virtualenv-20.25.0

[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: pip install --upgrade pip
##[group]Run python -m pip freeze --local
[36;1mpython -m pip freeze --local[0m
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  pythonLocation: /opt/hostedtoolcache/Python/3.12.0/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.12.0/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.0/x64/lib
##[endgroup]
cfgv==3.4.0
distlib==0.3.7
filelock==3.13.1
identify==2.5.32
nodeenv==1.8.0
platformdirs==4.1.0
pre-commit==3.5.0
PyYAML==6.0.1
setuptools==69.0.2
virtualenv==20.25.0
##[group]Run actions/cache@v3
with:
  path: ~/.cache/pre-commit
  key: pre-commit-3|/opt/hostedtoolcache/Python/3.12.0/x64|78083b3309c934e46e7d0a952b7a4c6dc6df8860edaa74474d06dd8c36e1b0a2
  enableCrossOsArchive: false
  fail-on-cache-miss: false
  lookup-only: false
env:
  pythonLocation: /opt/hostedtoolcache/Python/3.12.0/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.12.0/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.0/x64/lib
##[endgroup]
Cache Size: ~15 MB (15834028 B)
[command]/usr/bin/tar -xf /home/runner/work/_temp/57a1be88-e0dc-49f3-b641-71745b211e30/cache.tzst -P -C /home/runner/work/django-import-export/django-import-export --use-compress-program unzstd
Cache restored successfully
Cache restored from key: pre-commit-3|/opt/hostedtoolcache/Python/3.12.0/x64|78083b3309c934e46e7d0a952b7a4c6dc6df8860edaa74474d06dd8c36e1b0a2
##[group]Run pre-commit run --show-diff-on-failure --color=always --all-files
[36;1mpre-commit run --show-diff-on-failure --color=always --all-files[0m
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  pythonLocation: /opt/hostedtoolcache/Python/3.12.0/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.12.0/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.0/x64/lib
##[endgroup]
black....................................................................[42mPassed[m
isort....................................................................[42mPassed[m
flake8...................................................................[41mFailed[m
[2m- hook id: flake8[m
[2m- exit code: 1[m

[1mtests/core/tests/test_resources/test_resources.py[m[36m:[m4[36m:[m1[36m:[m [1m[31mF401[m 'copy.deepcopy' imported but unused

##[error]Process completed with exit code 1.


Changed files:
docs/changelog.rst
import_export/admin.py
tests/core/tests/test_resources/test_resources.py
tests/core/tests/test_results.py

Fix diff:
diff --git a/docs/changelog.rst b/docs/changelog.rst
index 09dc80c6..d20ed2e7 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -13,7 +13,6 @@ Please refer to :doc:`release notes<release_notes>`.
 - Import form defaults to read-only field if only one format defined (#1690)
 - Refactored :module:`~import_export.resources` into separate modules for ``declarative`` and ``options`` (#1695)
 - fix multiple inheritance not setting options (#1696)
-- Refactored tests to remove dependencies between tests (#1703)
 
 4.0.0-beta.1 (2023-11-16)
 --------------------------
diff --git a/import_export/admin.py b/import_export/admin.py
index 167a4fe1..66964e4f 100644
--- a/import_export/admin.py
+++ b/import_export/admin.py
@@ -207,7 +207,7 @@ class ImportMixin(BaseImportMixin, ImportExportMixinBase):
     def generate_log_entries(self, result, request):
         if not self.get_skip_admin_log():
             # Add imported objects to LogEntry
-            if django.VERSION >= (5, 0):
+            if django.VERSION >= (6, 0):
                 self._log_actions(result, request)
             else:
                 logentry_map = {
diff --git a/tests/core/tests/test_resources/test_resources.py b/tests/core/tests/test_resources/test_resources.py
index 82ef08bd..408317c7 100644
--- a/tests/core/tests/test_resources/test_resources.py
+++ b/tests/core/tests/test_resources/test_resources.py
@@ -1092,15 +1092,8 @@ class ModelResourceTest(TestCase):
 
     @ignore_widget_deprecation_warning
     def test_import_data_skip_unchanged(self):
-        class MyBookResource(resources.ModelResource):
-            save_count = 0
-
-            def save_instance(self, instance, is_create, row, **kwargs):
-                self.save_count += 1
-
-            class Meta:
-                skip_unchanged = True
-                model = Book
+        def attempted_save(instance, new, using_transactions, real_dry_run):
+            self.fail("Resource attempted to save instead of skipping")
 
         # Make sure we test with ManyToMany related objects
         cat1 = Category.objects.create(name="Cat 1")
@@ -1111,15 +1104,16 @@ class ModelResourceTest(TestCase):
 
         # Create a new resource that attempts to reimport the data currently
         # in the database while skipping unchanged rows (i.e. all of them)
-        resource = MyBookResource()
+        resource = deepcopy(self.resource)
+        resource._meta.skip_unchanged = True
+        # Fail the test if the resource attempts to save the row
+        resource.save_instance = attempted_save
         result = resource.import_data(dataset, raise_errors=True)
         self.assertFalse(result.has_errors())
         self.assertEqual(len(result.rows), len(dataset))
         self.assertTrue(result.rows[0].diff)
         self.assertEqual(result.rows[0].import_type, results.RowResult.IMPORT_TYPE_SKIP)
         self.assertEqual(result.rows[0].object_id, self.book.pk)
-        if resource.save_count > 0:
-            self.fail("Resource attempted to save instead of skipping")
 
         # Test that we can suppress reporting of skipped rows
         resource._meta.report_skipped = False
diff --git a/tests/core/tests/test_results.py b/tests/core/tests/test_results.py
index 35db0268..fa2e487c 100644
--- a/tests/core/tests/test_results.py
+++ b/tests/core/tests/test_results.py
@@ -56,8 +56,12 @@ class ResultTest(TestCase):
         self.assertEqual("", row_result.object_repr)
 
     def test_add_instance_info(self):
+        class BookWithObjectRepr(Book):
+            def __str__(self):
+                return self.name
+
         row_result = RowResult()
-        row_result.add_instance_info(Book(pk=1, name="some book"))
+        row_result.add_instance_info(BookWithObjectRepr(pk=1, name="some book"))
         self.assertEqual(1, row_result.object_id)
         self.assertEqual("some book", row_result.object_repr)