|
33 | 33 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
34 | 34 |
|
35 | 35 | import socket |
| 36 | + |
36 | 37 | from django.conf import settings |
37 | 38 | from django.template import TemplateDoesNotExist |
| 39 | +from django.test.simple import run_tests as django_run_tests |
| 40 | + |
38 | 41 | import ietf.utils.mail |
39 | | -from ietf.utils.mail import outbox as outbox |
40 | 42 |
|
41 | 43 | loaded_templates = set() |
42 | 44 | test_database_name = None |
@@ -72,19 +74,22 @@ def run_tests_1(test_labels, *args, **kwargs): |
72 | 74 | connection.creation.__class__.create_test_db = safe_create_1 |
73 | 75 | old_destroy = connection.creation.__class__.destroy_test_db |
74 | 76 | connection.creation.__class__.destroy_test_db = safe_destroy_0_1 |
75 | | - from django.test.simple import run_tests |
76 | 77 | if not test_labels: |
77 | 78 | settings.TEMPLATE_LOADERS = ('ietf.utils.test_runner.template_coverage_loader',) + settings.TEMPLATE_LOADERS |
78 | 79 | test_labels = [x.split(".")[-1] for x in settings.INSTALLED_APPS if x.startswith("ietf")] + ['redirects.TemplateCoverageTestCase',] |
| 80 | + if settings.SITE_ID != 1: |
| 81 | + print " Changing SITE_ID to '1' during testing, to avoid failures due to a missing site entry in the test DB." |
| 82 | + settings.SITE_ID = 1 |
| 83 | + assert(not settings.IDTRACKER_BASE_URL.endswith('/')) |
79 | 84 | kwargs["verbosity"] = 0 |
80 | | - run_tests(test_labels, *args, **kwargs) |
| 85 | + django_run_tests(test_labels, *args, **kwargs) |
81 | 86 |
|
82 | 87 | def run_tests(*args, **kwargs): |
83 | 88 | # Tests that involve switching back and forth between the real |
84 | 89 | # database and the test database are way too dangerous to run |
85 | 90 | # against the production database |
86 | | - if socket.gethostname().startswith("core3"): |
87 | | - raise EnvironmentError("Refusing to run tests on core3") |
| 91 | + if socket.gethostname().split('.')[0] in ['core3', 'ietfa', 'ietfb', 'ietfc', ]: |
| 92 | + raise EnvironmentError("Refusing to run tests on production server") |
88 | 93 | ietf.utils.mail.test_mode = True |
89 | 94 | run_tests_1(*args, **kwargs) |
90 | 95 |
|
0 commit comments