django / django-docker-box

Run the Django test suite across all supported databases and python versions
116 stars 37 forks source link

multiple check_framework.test_caches tests fail due to wrong working directory #38

Closed awtimmering closed 2 years ago

awtimmering commented 2 years ago

runtests.py is intended to be run from the tests/ directory. The current docker-compose.yml file however runs it from the parent directory, causing a number of tests to fail due to a lack of permissions (as they are pointing at a non-existant directory).

For example:

ERROR [0.004s]: test_absolute_path (check_framework.test_caches.CheckCacheAbsolutePath)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
    yield
  File "/usr/local/lib/python3.8/unittest/case.py", line 676, in run
    self._callTestMethod(testMethod)
  File "/usr/local/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
    method()
  File "/tests/django/tests/check_framework/test_caches.py", line 132, in test_absolute_path
    self.assertEqual(check_file_based_cache_is_absolute(None), [])
  File "/tests/django/django/core/checks/caches.py", line 63, in check_file_based_cache_is_absolute
    cache = caches[alias]
  File "/tests/django/django/utils/connection.py", line 62, in __getitem__
    conn = self.create_connection(alias)
  File "/tests/django/django/core/cache/__init__.py", line 44, in create_connection
    return backend_cls(location, params)
  File "/tests/django/django/core/cache/backends/filebased.py", line 23, in __init__
    self._createdir()
  File "/tests/django/django/core/cache/backends/filebased.py", line 121, in _createdir
    os.makedirs(self._dir, 0o700, exist_ok=True)
  File "/usr/local/lib/python3.8/os.py", line 223, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/tests/django/cache'

For future compatibility as well, it would be better to change the way runtests.py is run.

felixxm commented 2 years ago

Duplicate of #24.