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.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.order_management',
  31. 'oscar.apps.catalogue',
  32. 'oscar.apps.catalogue.reviews',
  33. 'oscar.apps.basket',
  34. 'oscar.apps.payment',
  35. 'oscar.apps.payment.datacash',
  36. 'oscar.apps.offer',
  37. 'oscar.apps.address',
  38. 'oscar.apps.partner',
  39. 'oscar.apps.customer',
  40. 'oscar.apps.promotions',
  41. 'oscar.apps.reports',
  42. 'oscar.apps.search',
  43. 'oscar.apps.voucher',
  44. ],
  45. TEMPLATE_CONTEXT_PROCESSORS=(
  46. "django.contrib.auth.context_processors.auth",
  47. "django.core.context_processors.request",
  48. "django.core.context_processors.debug",
  49. "django.core.context_processors.i18n",
  50. "django.core.context_processors.media",
  51. "django.core.context_processors.static",
  52. "django.contrib.messages.context_processors.messages",
  53. 'oscar.apps.search.context_processors.search_form',
  54. 'oscar.apps.promotions.context_processors.promotions',
  55. 'oscar.apps.checkout.context_processors.checkout',
  56. ),
  57. TEMPLATE_DIRS=(
  58. location('tests/templates'),
  59. ),
  60. MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES + (
  61. 'oscar.apps.basket.middleware.BasketMiddleware',
  62. ),
  63. AUTHENTICATION_BACKENDS=(
  64. 'oscar.apps.customer.auth_backends.Emailbackend',
  65. 'django.contrib.auth.backends.ModelBackend',
  66. ),
  67. ROOT_URLCONF='tests.urls',
  68. LOGIN_REDIRECT_URL='/accounts/',
  69. DEBUG=False,
  70. SITE_ID=1,
  71. HAYSTACK_SEARCH_ENGINE='dummy',
  72. HAYSTACK_SITECONF = 'oscar.search_sites',
  73. **oscar_settings
  74. )
  75. from django.test.simple import DjangoTestSuiteRunner
  76. def run_tests(*test_args):
  77. # Modify path
  78. parent = os.path.dirname(os.path.abspath(__file__))
  79. sys.path.insert(0, parent)
  80. # Run tests
  81. test_runner = DjangoTestSuiteRunner(verbosity=1)
  82. if not test_args:
  83. test_args = ['oscar']
  84. failures = test_runner.run_tests(test_args)
  85. sys.exit(failures)
  86. if __name__ == '__main__':
  87. parser = OptionParser()
  88. (options, args) = parser.parse_args()
  89. run_tests(*args)