This set of tests is manually executed today. These tests will be migrated to py.test and this notebook will be removed.
import add_parent_to_path
from ipy_table import *
array = [[0, 1, 2], [3, 4]]
try:
t = IpyTable(array)
except ValueError:
print 'Pass'
else:
print 'Fail'
Pass
array = [[0, 1], [2, 3]]
t = IpyTable(array)
try:
t.set_cell_style(2, 0, color='red')
except ValueError, error_text:
print 'Pass (%s)' % error_text
else:
print 'Fail'
Pass (Bad row (2). Expected row in range 0 to 1.)
array = [[0, 1], [2, 3]]
t = IpyTable(array)
try:
t.apply_theme("monty")
except ValueError, error_text:
print 'Pass (%s)' % error_text
else:
print 'Fail'
Pass (Unknown theme "monty". Expected one of ['basic', 'basic_left', 'basic_both'].)
import random
from random import randint
import string
import ipy_table as ipt
width = randint(1,6)
height = randint(1,6)
array = [[None for column in range(width)] for row in range(height)]
for row in range(height):
for column in range(width):
array[row][column] = random.choice([
random.random()*1000000,
''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(randint(1,14))),
randint(0, 1000000)])
make_table(array)
for i in range(20):
row = randint(0, height-1)
column = randint(0, width-1)
style = random.choice(['color', 'bold', 'thick_border', 'no_border'])
if style == 'color':
set_cell_style(row, column, color=random.choice(['red', 'blue', 'green']))
elif style == 'bold':
set_cell_style(row, column, bold=True)
elif style == 'thick_border':
set_cell_style(row, column, thick_border=random.choice(['left', 'right', 'top', 'bottom']))
elif style == 'no_border':
set_cell_style(row, column, no_border=random.choice(['left', 'right', 'top', 'bottom']))
ipt.render()
245665 | L1XGLVI | 544947 | 50927.9140 | EDK5MZR9VCK3 | 42715 |
727540.9032 | 982393.3803 | CSXKM2CC0 | C368 | 767060 | 740771.3891 |
703378 | W5 | I6MEB4 | 313052.8700 | OGVGYK3PAAPMIN | 32926 |
464622 | 69362.3007 | 649483 | 66F7 | 9N8L19X38R | 9NKSWP |
U73 | 195878 | L1 | 332384.1748 | 94ANOMO11HC | 605060.1725 |
119233.9238 | 669088.4642 | DV86U0E5VU5PL | 165453.7186 | 417924 | 968145.1539 |
array = [[0, 1], [2, 3]]
t = IpyTable(array)
try:
t.set_cell_style(0, 0, thick_border=True)
except TypeError, error_text:
print 'Pass (%s)' % error_text
else:
print 'Fail'
Pass (thick_border must be a string of comma separated border names (e.g. "left,right"))
try:
t.set_cell_style(0, 0, thick_border='left + bottom')
except ValueError, error_text:
print 'Pass (%s)' % error_text
else:
print 'Fail'
Pass (thick_border must be a string of comma separated border names (e.g. "left,right"). Valid border names: set(['top', 'right', 'bottom', 'all', 'left']))
array = [[0, 1], [2, 3]]
t = IpyTable(array)
try:
t.set_cell_style(0, 0, no_border=True)
except TypeError, error_text:
print 'Pass (%s)' % error_text
else:
print 'Fail'
Pass (no_border must be a string of comma separated border names (e.g. "left,right"))
try:
t.set_cell_style(0, 0, no_border='left + bottom')
except ValueError, error_text:
print 'Pass (%s)' % error_text
else:
print 'Fail'
Pass (no_border must be a string of comma separated border names (e.g. "left,right"). Valid border names: set(['top', 'right', 'bottom', 'all', 'left']))
a=make_table([(u'Unicode Characters: \xe9\u03a0\u03a3', 1),('test2',2)])
a._repr_html_()
u'<table border="1" cellpadding="3" cellspacing="0" style="border:black; border-collapse:collapse;"><tr><td style="border-top: 1px solid;border-right: 1px solid;border-bottom: 1px solid;border-left: 1px solid;">Unicode Characters: \xe9\u03a0\u03a3</td><td style="border-top: 1px solid;border-right: 1px solid;border-bottom: 1px solid;border-left: 1px solid;">1</td></tr><tr><td style="border-top: 1px solid;border-right: 1px solid;border-bottom: 1px solid;border-left: 1px solid;">test2</td><td style="border-top: 1px solid;border-right: 1px solid;border-bottom: 1px solid;border-left: 1px solid;">2</td></tr></table>'
a
Unicode Characters: éΠΣ | 1 |
test2 | 2 |
apply_theme('basic')
Unicode Characters: éΠΣ | 1 |
test2 | 2 |