revsys / django-test-plus

Useful additions to Django's default TestCase

Home Page:https://django-test-plus.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

1.1.0 breaks pytest

lgandras opened this issue · comments

Hi,

after upgrading from 1.0.22 to 1.1.0, i get suddenly the following stack trace:

(venv) user@host:~/project$ pytest 
Traceback (most recent call last):
  File "/home/user/project/venv/bin/pytest", line 11, in <module>
    sys.exit(main())
  File "/home/user/project/venv/lib/python3.5/site-packages/_pytest/config/__init__.py", line 56, in main
    config = _prepareconfig(args, plugins)
  File "/home/user/project/venv/lib/python3.5/site-packages/_pytest/config/__init__.py", line 181, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "/home/user/project/venv/lib/python3.5/site-packages/pluggy/__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/home/user/project/venv/lib/python3.5/site-packages/pluggy/__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/user/project/venv/lib/python3.5/site-packages/pluggy/__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "/home/user/project/venv/lib/python3.5/site-packages/pluggy/callers.py", line 196, in _multicall
    gen.send(outcome)
  File "/home/user/project/venv/lib/python3.5/site-packages/_pytest/helpconfig.py", line 89, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/home/user/project/venv/lib/python3.5/site-packages/pluggy/callers.py", line 76, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/user/project/venv/lib/python3.5/site-packages/pluggy/callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "/home/user/project/venv/lib/python3.5/site-packages/_pytest/config/__init__.py", line 607, in pytest_cmdline_parse
    self.parse(args)
  File "/home/user/project/venv/lib/python3.5/site-packages/_pytest/config/__init__.py", line 772, in parse
    self._preparse(args, addopts=addopts)
  File "/home/user/project/venv/lib/python3.5/site-packages/_pytest/config/__init__.py", line 724, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/home/user/project/venv/lib/python3.5/site-packages/pluggy/__init__.py", line 397, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/home/user/project/venv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2291, in load
    return self.resolve()
  File "/home/user/project/venv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/user/project/venv/lib/python3.5/site-packages/test_plus/__init__.py", line 1, in <module>
    from .test import APITestCase, TestCase
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
  File "/home/user/project/venv/lib/python3.5/site-packages/_pytest/assertion/rewrite.py", line 216, in load_module
    py.builtin.exec_(co, mod.__dict__)
  File "/home/user/project/venv/lib/python3.5/site-packages/test_plus/test.py", line 16, in <module>
    from .compat import reverse, NoReverseMatch, APIClient
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
  File "/home/user/project/venv/lib/python3.5/site-packages/_pytest/assertion/rewrite.py", line 216, in load_module
    py.builtin.exec_(co, mod.__dict__)
  File "/home/user/project/venv/lib/python3.5/site-packages/test_plus/compat.py", line 7, in <module>
    from rest_framework.test import APIClient
  File "/home/user/project/venv/lib/python3.5/site-packages/rest_framework/test.py", line 21, in <module>
    from rest_framework.compat import coreapi, requests
  File "/home/user/project/venv/lib/python3.5/site-packages/rest_framework/compat.py", line 107, in <module>
    from django.contrib.postgres import fields as postgres_fields
  File "/home/user/project/venv/lib/python3.5/site-packages/django/contrib/postgres/fields/__init__.py", line 1, in <module>
    from .array import *  # NOQA
  File "/home/user/project/venv/lib/python3.5/site-packages/django/contrib/postgres/fields/array.py", line 3, in <module>
    from django.contrib.postgres import lookups
  File "/home/user/project/venv/lib/python3.5/site-packages/django/contrib/postgres/lookups.py", line 4, in <module>
    from .search import SearchVector, SearchVectorExact, SearchVectorField
  File "/home/user/project/venv/lib/python3.5/site-packages/django/contrib/postgres/search.py", line 47, in <module>
    class SearchVector(SearchVectorCombinable, Func):
  File "/home/user/project/venv/lib/python3.5/site-packages/django/contrib/postgres/search.py", line 50, in SearchVector
    _output_field = SearchVectorField()
  File "/home/user/project/venv/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 172, in __init__
    self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
  File "/home/user/project/venv/lib/python3.5/site-packages/django/conf/__init__.py", line 56, in __getattr__
    self._setup(name)
  File "/home/user/project/venv/lib/python3.5/site-packages/django/conf/__init__.py", line 39, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

In case it is important, these are the requirements for the project:

bleach==2.1.3
dj-database-url==0.5.0
Django==1.11.11
django-admin-sortable2==0.6.19
django-bleach==0.3.0
django-classy-tags==0.8.0
django-cms==3.5.2
django-constance[database]==2.2.0
django-cors-headers==2.2.0
django-enumfields==0.10.1
django-finalware==1.0.0
django-filer==1.3.2
django-formtools==2.1
django-htmlmin==0.10.0
django-nested-admin==3.0.21
python-monkey-business==1.0.0
django-ipware==2.1.0
django-polymorphic==2.0.2
django-reversion==2.0.13
django-sass-processor==0.7
django-sekizai==0.10.0
Django-Select2==6.0.3
django-settings-export==1.2.1
django-simple-history==2.1.1
django-sortedm2m==1.5.0
django-treebeard==4.3
djangocms-admin-style==1.2.8
djangocms-attributes-field==0.3.0
djangocms-cascade==0.16.2
djangocms-column==1.7.0
djangocms-inherit==0.2.2
djangocms-link==2.1.2
djangocms-picture==2.0.6
djangocms-style==2.0.2
djangocms-teaser==0.2.0
djangocms-video==2.0.4
djangorestframework==3.8.2
html5lib==1.0.1
iptools==0.6.1
libsass==0.14.5
Pillow==5.1.0
psycopg2-binary==2.7.5
pytz==2018.4
six==1.11.0
tzlocal==1.5.1
enum34==1.1.6
webencodings==0.5.1
beautifulsoup4==4.6.0
lxml==4.2.2
elasticsearch==6.3.0
elasticsearch-dsl==6.1.0

django-compressor==2.2
django-appconf==1.0.2
rcssmin==1.0.6
rjsmin==1.0.12

brotlipy==0.7.0
cffi==1.11.5
django-brotli==0.1.3
pycparser==2.18

django-sslserver==0.20

polib==1.1.0

coverage==4.5.1
cobertura-clover-transform==1.1.4.post1
django-coverage-plugin==1.5.0
django-test-plus==1.0.22
factory-boy==2.11.1
tblib==1.3.2

flake8==3.5.0
pytest==3.6.2
pytest-django==3.3.2
pytest-sugar==0.9.1
pytest-cov==2.5.1
pytest-xdist==1.22.2
pytest-flake8==1.0.1
pytest-html==1.19.0
freezegun==0.3.10
parameterized==0.6.1

django-debug-toolbar==1.9.1
ipython==6.4.0

Sphinx==1.7.5
sphinx-rtd-theme==0.4.0

As you can notice in the stack trace, django-test-plus attempts to read the settings before they are actually loaded by pytest. Rolling back to 1.0.22 solves this issue for me.

I have exactly the same issue.
I am also using djangorestframework, but the version doesn't matter.
Rolling back to django-test-plus 1.0.22 solved the issue.

I have the same issue. Rolling back to django-test-plus 1.0.22 also resolves it for me.

This should be fixed in master. Note that it's not released on PyPI yet.

@frankwiles can you please roll a new version when you get a sec?

Ok this is released as v1.1.1 sorry about that regression! Thanks @fcurella for getting it fixed!