Skip to content

Commit deecbc9

Browse files
committed
Don't list URLs which have explicit tests as Skipped during the fallback URL test.
- Legacy-Id: 307
1 parent 7f512b4 commit deecbc9

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

ietf/tests.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ def setUp(self):
8484
if "testurls.list" in files:
8585
self.testtuples += read_testurls(root+"/testurls.list")
8686
self.testurls = [ tuple[1] for tuple in self.testtuples ]
87+
88+
# extract application urls:
89+
self.patterns = get_patterns(ietf.urls)
8790
# Use the default database for the url tests, instead of the test database
8891
self.testdb = settings.DATABASE_NAME
8992
connection.close()
@@ -98,16 +101,15 @@ def tearDown(self):
98101

99102
def testCoverage(self):
100103
covered = []
101-
patterns = get_patterns(ietf.urls)
102104
for codes, testurl, goodurl in self.testtuples:
103-
for pattern in patterns:
105+
for pattern in self.patterns:
104106
if re.match(pattern, testurl[1:]):
105107
covered.append(pattern)
106108
# We should have at least one test case for each url pattern declared
107109
# in our Django application:
108110
#self.assertEqual(set(patterns), set(covered), "Not all the
109111
#application URLs has test cases. The missing are: %s" % (list(set(patterns) - set(covered))))
110-
if not set(patterns) == set(covered):
112+
if not set(self.patterns) == set(covered):
111113
#print "Not all the application URLs has test cases. The missing are: \n %s" % ("\n ".join(list(set(patterns) - set(covered))))
112114
print "Not all the application URLs has test cases."
113115

@@ -183,18 +185,17 @@ def testUrlsList(self):
183185
self.doUrlsTest(self.testtuples)
184186

185187
def testUrlsFallback(self):
186-
patterns = get_patterns(ietf.urls)
188+
print "\nFallback: Test access to URLs which don't have an explicit test entry:"
187189
lst = []
188-
for pattern in patterns:
190+
for pattern in self.patterns:
189191
if pattern.startswith("^") and pattern.endswith("$"):
190192
url = "/"+pattern[1:-1]
191193
# if there is no variable parts in the url, test it
192194
if re.search("^[-a-z0-9./_]*$", url) and not url in self.testurls and not url.startswith("/admin/"):
193195
lst.append((["200"], url, None))
194196
else:
195-
lst.append((["skip"], url, None))
197+
print "Test exists for %s" % (url)
196198
else:
197199
lst.append((["Skip"], url, None))
198200

199-
print "\nTesting non-listed URLs:"
200201
self.doUrlsTest(lst)

0 commit comments

Comments
 (0)