Accept both testurl.list and testurls.list as test url list file names. Output status for good compares, too.
- Legacy-Id: 303
This commit is contained in:
parent
9b78963547
commit
b42e0728c8
|
@ -51,17 +51,8 @@ def get_patterns(module):
|
|||
all.append(item.regex.pattern + ".*" + sub)
|
||||
return all
|
||||
|
||||
class UrlTestCase(TestCase):
|
||||
def setUp(self):
|
||||
from django.test.client import Client
|
||||
self.client = Client()
|
||||
|
||||
# find test urls
|
||||
self.testtuples = []
|
||||
self.testurls = []
|
||||
for root, dirs, files in os.walk(settings.BASE_DIR):
|
||||
if "testurl.list" in files:
|
||||
filename = root+"/testurl.list" # yes, this is non-portable
|
||||
def read_testurls(filename):
|
||||
tuples = []
|
||||
file = open(filename)
|
||||
for line in file:
|
||||
line = line.strip()
|
||||
|
@ -76,9 +67,23 @@ class UrlTestCase(TestCase):
|
|||
else:
|
||||
raise ValueError("Expected 'HTTP_CODE TESTURL [GOODURL]' in %s line, found '%s'." % (filename, line))
|
||||
codes = codes.split(",")
|
||||
self.testtuples += [ (codes, testurl, goodurl) ]
|
||||
self.testurls += [ testurl ]
|
||||
#print "(%s, %s, %s)" % (code, testurl, goodurl)
|
||||
tuples += [ (codes, testurl, goodurl) ]
|
||||
return tuples
|
||||
|
||||
class UrlTestCase(TestCase):
|
||||
def setUp(self):
|
||||
from django.test.client import Client
|
||||
self.client = Client()
|
||||
|
||||
# find test urls
|
||||
self.testtuples = []
|
||||
self.testurls = []
|
||||
for root, dirs, files in os.walk(settings.BASE_DIR):
|
||||
if "testurl.list" in files:
|
||||
self.testtuples += read_testurls(root+"/testurl.list")
|
||||
if "testurls.list" in files:
|
||||
self.testtuples += read_testurls(root+"/testurls.list")
|
||||
self.testurls = [ tuple[0] for tuple in self.testtuples ]
|
||||
# Use the default database for the url tests, instead of the test database
|
||||
self.testdb = settings.DATABASE_NAME
|
||||
connection.close()
|
||||
|
@ -136,7 +141,9 @@ class UrlTestCase(TestCase):
|
|||
if goodhtml and response.content:
|
||||
testtext = reduce(response.content)
|
||||
goodtext = reduce(goodhtml)
|
||||
if not testtext == goodtext:
|
||||
if testtext == goodtext:
|
||||
print "OK cmp %s" % (url)
|
||||
else:
|
||||
diff = "\n".join(unified_diff(goodtext, testtext, url, master, lineterm=False))
|
||||
dfile = "%s/../test/diff/%s" % (settings.BASE_DIR, url.replace("/", "_"))
|
||||
if os.path.exists(dfile):
|
||||
|
|
|
@ -27,7 +27,10 @@ def para(words, pre):
|
|||
text = text.replace(entity, char)
|
||||
if not pre:
|
||||
text = re.sub("[\r\n\t ]+", " ", text)
|
||||
try: # On OS-X / Python 2.5 textwrap can throw a runtime error
|
||||
text = textwrap.fill(text)
|
||||
except RuntimeError:
|
||||
pass
|
||||
return text
|
||||
|
||||
def render(node, encoding='latin-1', pre=False):
|
||||
|
|
Loading…
Reference in a new issue