In [1]:
    
%run tabipy.py
    
In [2]:
    
t = Table((1,2,3),
          (4,5,6),
          (7,8,9))
t
    
    Out[2]:
In [3]:
    
cell_1_1 = t.rows[0].cells[0]
cell_1_1.col_span = 2
    
In [4]:
    
t
    
    Out[4]:
In [5]:
    
t1_html = t._repr_html_()
print(t1_html)
t1_html
    
    
    Out[5]:
In [6]:
    
t1_latex = t._repr_latex_()
print(t1_latex)
    
    
In [7]:
    
t1_latex
    
    Out[7]:
In [8]:
    
t = Table((TableCell(1,col_span=2),2,3),
          (4,5,6,7),
          (8,9,10,11))
t
    
    Out[8]:
In [9]:
    
print(t._repr_latex_())
    
    
In [10]:
    
r1 = t.rows[0]
c1 = r1.cells[0]
c1.col_span=1
    
In [11]:
    
t
    
    Out[11]:
In [12]:
    
print(t._repr_html_())
    
    
In [13]:
    
import re
def col_span_table():
    t = Table((1,2,3),
      (4,5,6),
      (7,8,9))
    cell_1_1 = t.rows[0].cells[0]
    cell_1_1.col_span = 2
    return t
def test_col_span_html():
    "This test col_span works in html"
    t = col_span_table()
    t1_html = t._repr_html_()
    row_split = re.compile('<\s*tr\s*>')
    lines = row_split.split(t1_html)
    assert len(lines)==4
    col_split = re.compile('>[\s\d\s]*<')
    parts = col_split.split(lines[1])
    cl_check = re.compile('colspan\s*=\s*"\s*2\s*"')
    assert len(cl_check.findall(parts[0]))>0
    #print("pass")
def test_col_span_latex():
    "This test col_span works in latex"
    t = col_span_table()    
    t1_latex = t._repr_latex_()
    row_split = re.compile(r'\\\\')
    lines = row_split.split(t1_latex)
    assert len(lines)==4
    col_split = re.compile('&')
    parts = col_split.split(lines[0])
    cl_check = re.compile('\w*\\multicolumn\s*\{\s*2\s*}')
    assert len(cl_check.findall(parts[0]))>0
    #print("pass")
    
test_col_span_html()
test_col_span_latex()