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.

run_tests.py 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/usr/bin/env python
  2. import sys
  3. import os
  4. from optparse import OptionParser
  5. from django.conf import settings, global_settings
  6. if not settings.configured:
  7. from oscar.defaults import *
  8. oscar_settings = dict([(k, v) for k, v in locals().items() if k.startswith('OSCAR_')])
  9. # Helper function to extract absolute path
  10. location = lambda x: os.path.join(os.path.dirname(os.path.realpath(__file__)), x)
  11. settings.configure(
  12. DATABASES={
  13. 'default': {
  14. 'ENGINE': 'django.db.backends.sqlite3',
  15. }
  16. },
  17. INSTALLED_APPS=[
  18. 'django.contrib.auth',
  19. 'django.contrib.admin',
  20. 'django.contrib.contenttypes',
  21. 'django.contrib.sessions',
  22. 'django.contrib.sites',
  23. # Oscar apps
  24. 'oscar',
  25. 'oscar.apps.analytics',
  26. 'oscar.apps.discount',
  27. 'oscar.apps.order',
  28. 'oscar.apps.checkout',
  29. 'oscar.apps.shipping',
  30. 'oscar.apps.catalogue',
  31. 'oscar.apps.catalogue.reviews',
  32. 'oscar.apps.basket',
  33. 'oscar.apps.payment',
  34. 'oscar.apps.offer',
  35. 'oscar.apps.address',
  36. 'oscar.apps.partner',
  37. 'oscar.apps.customer',
  38. 'oscar.apps.promotions',
  39. 'oscar.apps.reports',
  40. 'oscar.apps.search',
  41. 'oscar.apps.voucher',
  42. 'oscar.apps.dashboard',
  43. ],
  44. TEMPLATE_CONTEXT_PROCESSORS=(
  45. "django.contrib.auth.context_processors.auth",
  46. "django.core.context_processors.request",
  47. "django.core.context_processors.debug",
  48. "django.core.context_processors.i18n",
  49. "django.core.context_processors.media",
  50. "django.core.context_processors.static",
  51. "django.contrib.messages.context_processors.messages",
  52. 'oscar.apps.search.context_processors.search_form',
  53. 'oscar.apps.promotions.context_processors.promotions',
  54. 'oscar.apps.checkout.context_processors.checkout',
  55. ),
  56. TEMPLATE_DIRS=(
  57. location('tests/templates'),
  58. ),
  59. MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES + (
  60. 'oscar.apps.basket.middleware.BasketMiddleware',
  61. ),
  62. AUTHENTICATION_BACKENDS=(
  63. 'oscar.apps.customer.auth_backends.Emailbackend',
  64. 'django.contrib.auth.backends.ModelBackend',
  65. ),
  66. ROOT_URLCONF='tests.urls',
  67. LOGIN_REDIRECT_URL='/accounts/',
  68. DEBUG=False,
  69. SITE_ID=1,
  70. HAYSTACK_SEARCH_ENGINE='dummy',
  71. HAYSTACK_SITECONF = 'oscar.search_sites',
  72. **oscar_settings
  73. )
  74. from django.test.simple import DjangoTestSuiteRunner
  75. def run_tests(*test_args):
  76. # Modify path
  77. parent = os.path.dirname(os.path.abspath(__file__))
  78. sys.path.insert(0, parent)
  79. # Run tests
  80. test_runner = DjangoTestSuiteRunner(verbosity=1)
  81. if not test_args:
  82. test_args = ['oscar']
  83. failures = test_runner.run_tests(test_args)
  84. sys.exit(failures)
  85. if __name__ == '__main__':
  86. parser = OptionParser()
  87. (options, args) = parser.parse_args()
  88. run_tests(*args)