chibisov / drf-extensions

DRF-extensions is a collection of custom extensions for Django REST Framework
http://chibisov.github.io/drf-extensions/docs
MIT License
1.48k stars 208 forks source link

Tests suite is failing with DRF 3.15.0 and beyond #341

Closed tijuca closed 2 months ago

tijuca commented 8 months ago

Running the tests of drf-extensions with a recent version 3.15.0+ of Django REST framework provoke a failing with this error message that is similar for all failing tests.

I: pybuild base:305: PYTHONPATH='.:tests_app' python3.12 /usr/bin/django-admin test --settings=settings tests_app
nosetests tests_app --processes=12 --process-timeout=100 --nocapture --verbosity=1
Creating test database for alias 'default'...
E/usr/lib/python3.12/unittest/case.py:580: RuntimeWarning: TestResult has no addDuration method
  warnings.warn("TestResult has no addDuration method",
EEEE..EEE..EEEEEEEEEEEEEEEEEEEE.EEEEEEEEEEEE...........EEEEEE.............................................................................................................................................EEEEEEEEEEEEEEEEEE
======================================================================
ERROR: Failure: ImproperlyConfigured (Router with basename "comment" is already registered. Please provide a unique basename for viewset "<class 'tests_app.tests.functional.mixins.detail_serializer_mixin.views.CommentWithoutDetailSerializerClassViewSet'>")
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/usr/lib/python3/dist-packages/nose/loader.py", line 416, in loadTestsFromName
    module = self.importer.importFromPath(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/zombie_imp/imp_3_11.py", line 238, in load_module
    return load_source(name, filename, file)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/zombie_imp/imp_3_11.py", line 175, in load_source
    module = _load(spec)
             ^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 966, in _load
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/build/drf-extensions-0.7.1/tests_app/tests/functional/mixins/detail_serializer_mixin/urls.py", line 14, in <module>
    viewset_router.register('comments-2', CommentWithoutDetailSerializerClassViewSet)
  File "/usr/lib/python3/dist-packages/rest_framework/routers.py", line 59, in register
    raise ImproperlyConfigured(msg)
django.core.exceptions.ImproperlyConfigured: Router with basename "comment" is already registered. Please provide a unique basename for viewset "<class 'tests_app.tests.functional.mixins.detail_serializer_mixin.views.CommentWithoutDetailSerializerClassViewSet'>"

A full output of the tests run is visible here https://ci.debian.net/packages/d/drf-extensions/testing/amd64/44283253/

Root for this behavior is a change in DRF 3.15.0 made in https://github.com/encode/django-rest-framework/pull/8438 if the basename is not unique.

https://www.django-rest-framework.org/community/release-notes/#315x-series