From 63754d4b2b24c3dd8ba1f8d1df505e084ae38058 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz <henrik@levkowetz.com> Date: Sun, 17 Jun 2007 11:09:52 +0000 Subject: [PATCH] The URL tests in tests.py can now limit the tests to be run to given URL prefixes. The test class looks for an environment variable URLPREFIX, and if it exists and is non-empty, it is expected to contain a space-separated list of URL prefix patterns for which tests should be run. test/run has been updated to place arguments given on the command line in the URLPREFIX environment variable, so you can say: {{{ $ test/run ipr }}} and only the URLs which start with /ipr will be tested. - Legacy-Id: 468 --- ietf/tests.py | 8 ++++++++ test/run | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ietf/tests.py b/ietf/tests.py index a9dd1a3d5..dd0d10652 100644 --- a/ietf/tests.py +++ b/ietf/tests.py @@ -107,6 +107,9 @@ class UrlTestCase(TestCase): from django.test.client import Client self.client = Client() + # get selected prefixes, if any + self.prefixes = os.environ.get("URLPREFIX", "").split() + # find test urls self.testtuples = [] self.testurls = [] @@ -133,6 +136,11 @@ class UrlTestCase(TestCase): # extract application urls: self.patterns = get_patterns(ietf.urls) + + # apply prefix filters + self.patterns = [ pattern for pattern in self.patterns for prefix in self.prefixes if re.match(prefix, pattern) ] + self.testtuples = [ tuple for tuple in self.testtuples for prefix in self.prefixes if re.match(prefix, tuple[1][1:]) ] + # Use the default database for the url tests, instead of the test database self.testdb = settings.DATABASE_NAME connection.close() diff --git a/test/run b/test/run index 2331a7615..05ebc96f0 100755 --- a/test/run +++ b/test/run @@ -13,7 +13,7 @@ test/run-pyflakes ietf trap 'echo "$program($LINENO): Caught Interrupt"' INT # run tests with our patched django -PYTHONPATH=test:test/lib python ietf/manage.py test +PYTHONPATH=test:test/lib URLPREFIX="$*" python ietf/manage.py test # reset keyboard interrupt trap trap INT