You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

conftest.py 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. import os
  2. import warnings
  3. import django
  4. def pytest_addoption(parser):
  5. parser.addoption('--postgres', action='store_true')
  6. parser.addoption(
  7. '--deprecation', choices=['strict', 'log', 'none'], default='log')
  8. def pytest_configure(config):
  9. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.settings')
  10. deprecation = config.getoption('deprecation')
  11. if deprecation == 'strict':
  12. warnings.simplefilter('error', DeprecationWarning)
  13. warnings.simplefilter('error', PendingDeprecationWarning)
  14. warnings.simplefilter('error', RuntimeWarning)
  15. if deprecation == 'log':
  16. warnings.simplefilter('always', DeprecationWarning)
  17. warnings.simplefilter('always', PendingDeprecationWarning)
  18. warnings.simplefilter('always', RuntimeWarning)
  19. elif deprecation == 'none':
  20. # Deprecation warnings are ignored by default
  21. pass
  22. if config.getoption('postgres'):
  23. os.environ['DATABASE_ENGINE'] = 'django.db.backends.postgresql_psycopg2'
  24. os.environ['DATABASE_NAME'] = 'oscar'
  25. django.setup()