Skip to content

Commit 63754d4

Browse files
committed
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
1 parent e40af43 commit 63754d4

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

ietf/tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ def setUp(self):
107107
from django.test.client import Client
108108
self.client = Client()
109109

110+
# get selected prefixes, if any
111+
self.prefixes = os.environ.get("URLPREFIX", "").split()
112+
110113
# find test urls
111114
self.testtuples = []
112115
self.testurls = []
@@ -133,6 +136,11 @@ def setUp(self):
133136

134137
# extract application urls:
135138
self.patterns = get_patterns(ietf.urls)
139+
140+
# apply prefix filters
141+
self.patterns = [ pattern for pattern in self.patterns for prefix in self.prefixes if re.match(prefix, pattern) ]
142+
self.testtuples = [ tuple for tuple in self.testtuples for prefix in self.prefixes if re.match(prefix, tuple[1][1:]) ]
143+
136144
# Use the default database for the url tests, instead of the test database
137145
self.testdb = settings.DATABASE_NAME
138146
connection.close()

test/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test/run-pyflakes ietf
1313
trap 'echo "$program($LINENO): Caught Interrupt"' INT
1414

1515
# run tests with our patched django
16-
PYTHONPATH=test:test/lib python ietf/manage.py test
16+
PYTHONPATH=test:test/lib URLPREFIX="$*" python ietf/manage.py test
1717

1818
# reset keyboard interrupt trap
1919
trap INT

0 commit comments

Comments
 (0)