Convert tests to pytest

This commit is contained in:
Andreas Kloeckner 2016-03-31 09:15:31 -05:00
parent 9b3601609d
commit 7c2585c03c
7 changed files with 60 additions and 45 deletions

View File

@ -25,6 +25,7 @@ setup(name='pudb',
install_requires=[
"urwid>=1.1.1",
"pygments>=1.0",
"pytest>=2",
],
url='http://pypi.python.org/pypi/pudb',
classifiers=[

59
test/test_make_canvas.py Normal file
View File

@ -0,0 +1,59 @@
# - encoding: utf-8 -
from pudb.ui_tools import make_canvas
def test_simple():
text = u'aaaaaa'
canvas = make_canvas(
txt=[text],
attr=[[('var value', len(text))]],
maxcol=len(text) + 5
)
content = list(canvas.content())
assert content == [
[('var value', None, b'aaaaaa'), (None, None, b' ' * 5)]
]
def test_multiple():
canvas = make_canvas(
txt=[u'Return: None'],
attr=[[('return label', 8), ('return value', 4)]],
maxcol=100
)
content = list(canvas.content())
assert content == [
[('return label', None, b'Return: '),
('return value', None, b'None'),
(None, None, b' ' * 88)]
]
def test_boundary():
text = u'aaaaaa'
canvas = make_canvas(
txt=[text],
attr=[[('var value', len(text))]],
maxcol=len(text)
)
assert list(canvas.content()) == [[('var value', None, b'aaaaaa')]]
def test_byte_boundary():
text = u'aaaaaaé'
canvas = make_canvas(
txt=[text],
attr=[[('var value', len(text))]],
maxcol=len(text)
)
assert list(canvas.content()) == [[('var value', None, b'aaaaaa\xc3\xa9')]]
if __name__ == "__main__":
import sys
if len(sys.argv) > 1:
exec(sys.argv[1])
else:
from py.test.cmdline import main
main([__file__])

View File

@ -1,45 +0,0 @@
from pudb.ui_tools import make_canvas
class TestMakeCanvas():
def test_simple(self):
text = u'aaaaaa'
canvas = make_canvas(
txt=[text],
attr=[[('var value', len(text))]],
maxcol=len(text) + 5
)
content = list(canvas.content())
assert content == [
[('var value', None, b'aaaaaa'), (None, None, b' ' * 5)]
]
def test_multiple(self):
canvas = make_canvas(
txt=[u'Return: None'],
attr=[[('return label', 8), ('return value', 4)]],
maxcol=100
)
content = list(canvas.content())
assert content == [
[('return label', None, b'Return: '),
('return value', None, b'None'),
(None, None, b' ' * 88)]
]
def test_boundary(self):
text = u'aaaaaa'
canvas = make_canvas(
txt=[text],
attr=[[('var value', len(text))]],
maxcol=len(text)
)
assert list(canvas.content()) == [[('var value', None, b'aaaaaa')]]
def test_byte_boundary(self):
text = u'aaaaaaé'
canvas = make_canvas(
txt=[text],
attr=[[('var value', len(text))]],
maxcol=len(text)
)
assert list(canvas.content()) == [[('var value', None, b'aaaaaa\xc3\xa9')]]