Adds test suite for tableprint

This commit is contained in:
Niru Maheswaranathan
2016-05-03 17:35:15 -07:00
parent cadf2eb8d8
commit f898aa7bf1
4 changed files with 84 additions and 15 deletions

26
tests/test_functions.py Normal file
View File

@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from tableprint import top, bottom, row
import pytest
def test_borders():
# top
assert top(5, width=2, style='round') == '╭──┬──┬──┬──┬──╮'
assert top(1, width=6, style='grid') == '+------+'
# bottom
assert bottom(3, width=1, style='fancy_grid') == '╘═╧═╧═╛'
assert bottom(3, 4, style='clean') == ' ──── ──── ──── '
def test_row():
# valid
assert row("abc", width=3, style='round') == '│ a│ b│ c│'
assert row([1, 2, 3], width=3, style='clean') == ' 1 2 3 '
# invalid
with pytest.raises(ValueError) as context:
row([{}])