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
This commit is contained in:
parent
e40af4343f
commit
63754d4b2b
|
@ -107,6 +107,9 @@ class UrlTestCase(TestCase):
|
||||||
from django.test.client import Client
|
from django.test.client import Client
|
||||||
self.client = Client()
|
self.client = Client()
|
||||||
|
|
||||||
|
# get selected prefixes, if any
|
||||||
|
self.prefixes = os.environ.get("URLPREFIX", "").split()
|
||||||
|
|
||||||
# find test urls
|
# find test urls
|
||||||
self.testtuples = []
|
self.testtuples = []
|
||||||
self.testurls = []
|
self.testurls = []
|
||||||
|
@ -133,6 +136,11 @@ class UrlTestCase(TestCase):
|
||||||
|
|
||||||
# extract application urls:
|
# extract application urls:
|
||||||
self.patterns = get_patterns(ietf.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
|
# Use the default database for the url tests, instead of the test database
|
||||||
self.testdb = settings.DATABASE_NAME
|
self.testdb = settings.DATABASE_NAME
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
2
test/run
2
test/run
|
@ -13,7 +13,7 @@ test/run-pyflakes ietf
|
||||||
trap 'echo "$program($LINENO): Caught Interrupt"' INT
|
trap 'echo "$program($LINENO): Caught Interrupt"' INT
|
||||||
|
|
||||||
# run tests with our patched django
|
# 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
|
# reset keyboard interrupt trap
|
||||||
trap INT
|
trap INT
|
||||||
|
|
Loading…
Reference in a new issue