def test_SimpleTable_3(self): """ Test SimpleTable.extend() as in extend down""" desired = ''' ============================== header s1 header d1 ------------------------------ stub R1 C1 10.30312 10.73999 stub R2 C1 90.30312 90.73999 header s2 header d2 ------------------------------ stub R1 C2 50.95038 50.65765 stub R2 C2 40.95038 40.65765 ------------------------------ ''' data1 = [[10.30312, 10.73999], [90.30312, 90.73999]] data2 = [[50.95038, 50.65765], [40.95038, 40.65765]] stubs1 = ['stub R1 C1', 'stub R2 C1'] stubs2 = ['stub R1 C2', 'stub R2 C2'] header1 = ['header s1', 'header d1'] header2 = ['header s2', 'header d2'] actual1 = SimpleTable(data1, header1, stubs1, txt_fmt=default_txt_fmt) actual2 = SimpleTable(data2, header2, stubs2, txt_fmt=default_txt_fmt) actual1.extend(actual2) actual = '\n%s\n' % actual1.as_text() self.assertEqual(desired, str(actual))
def test_SimpleTable_1(self): """Basic test, test_SimpleTable_1""" desired = ''' ===================== header1 header2 --------------------- stub1 1.30312 2.73999 stub2 1.95038 2.65765 --------------------- ''' test1data = [[1.30312, 2.73999],[1.95038, 2.65765]] test1stubs = ('stub1', 'stub2') test1header = ('header1', 'header2') actual = SimpleTable(test1data, test1header, test1stubs, txt_fmt=default_txt_fmt) actual = '\n%s\n' % actual.as_text() self.assertEqual(desired, str(actual))
def test_SimpleTable_1(self): """Basic test, test_SimpleTable_1""" desired = ''' ===================== header1 header2 --------------------- stub1 1.30312 2.73999 stub2 1.95038 2.65765 --------------------- ''' test1data = [[1.30312, 2.73999], [1.95038, 2.65765]] test1stubs = ('stub1', 'stub2') test1header = ('header1', 'header2') actual = SimpleTable(test1data, test1header, test1stubs, txt_fmt=default_txt_fmt) actual = '\n%s\n' % actual.as_text() self.assertEqual(desired, str(actual))
def test_customlabel(self): """Limited test of custom custom labeling""" if has_numpy: tbl = SimpleTable(table1data, test1header, test1stubs, txt_fmt=txt_fmt1) tbl[1][1].data = np.nan tbl.label_cells(custom_labeller) #print([[c.datatype for c in row] for row in tbl]) desired = """ ***************************** * * header1 * header2 * ***************************** * stub1 * -- * 1 * * stub2 * 2.00 * 3 * ***************************** """ actual = '\n%s\n' % tbl.as_text(missing='--') #print(actual) #print(desired) self.assertEqual(actual, desired)