Modify tests to run with py.test.

This removes a dependancy on Sancho for running tests.
This commit is contained in:
Neil Schemenauer 2016-10-04 13:07:07 -07:00
parent 7dc58b8c88
commit 9352cfe80e
4 changed files with 27 additions and 6 deletions

View File

@ -1,7 +1,7 @@
import sys
from sancho.utest import UTest
from quixote.html import _py_htmltext
from quixote.html import href, url_with_query, url_quote, nl2br
from quixote.test.utest import UTest
markupchars = '<>&"'
quotedchars = '&lt;&gt;&amp;&quot;'
@ -340,7 +340,7 @@ def setup_c():
TemplateIO = _c_htmltext.TemplateIO
if __name__ == "__main__":
def test_all():
setup_py()
HTMLTest()
HTMLTextTest()
@ -350,3 +350,6 @@ if __name__ == "__main__":
HTMLTest()
HTMLTextTest()
TemplateTest()
if __name__ == "__main__":
test_all()

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python
from sancho.utest import UTest
from quixote.test.utest import UTest
from quixote.ptl.ptl_compile import compile_template
from io import StringIO
from quixote.html import TemplateIO, htmltext
@ -53,6 +53,8 @@ class Test (UTest):
except SyntaxError as e:
assert e.lineno == 1
if __name__ == "__main__":
def test_all():
Test()
if __name__ == "__main__":
test_all()

View File

@ -1,4 +1,4 @@
from sancho.utest import UTest
from quixote.test.utest import UTest
from quixote.http_request import parse_cookies
@ -39,5 +39,8 @@ class ParseCookiesTest (UTest):
parse_cookies('a="123')
parse_cookies('a=123"')
if __name__ == "__main__":
def test_all():
ParseCookiesTest()
if __name__ == "__main__":
test_all()

13
quixote/test/utest.py Normal file
View File

@ -0,0 +1,13 @@
# Minimal class to make old Sancho tests work with py.test.
import types
class UTest:
def __init__(self):
print('Running %s:' % self.__class__.__name__)
for name in dir(self):
# Find all methods starting with check_, call them.
if name.startswith('check_'):
method = getattr(self, name)
if isinstance(method, types.MethodType):
print(' ', name)
method()