def test_set_dimensions__marks_dirty(self): g = Grid([[Text('a')]]) with self.assertMarksDirty(g): g.n_rows = 2 with self.assertMarksDirty(g): g.n_rows = 0 with self.assertMarksDirty(g): g.n_rows = 1 with self.assertMarksDirty(g): g.n_columns = 2 with self.assertMarksDirty(g): g.n_columns = 0 with self.assertMarksDirty(g): g.n_columns = 1
def test_set_n_rows(self): a, b, c, d = Text('a'), Text('b'), Text('c'), Text('d') g = Grid([[a, b], [c, d]]) g.n_rows = 1 self.assertEqual(g, a.parent) self.assertEqual(g, b.parent) self.assertIsNone(c.parent) self.assertIsNone(d.parent) self.assertEqual([a,b], list(g.children)) self.assertEqual(1, g.n_rows) with self.assertRaises(IndexError): g[1,0] self.assertUnstyledHTMLLike(grid_of_text_xml(['a','b']), g) g.n_rows = 2 self.assertIsNone(g[1,0]) self.assertEqual([a,b], list(g.children)) g[1,0] = c self.assertEqual(g, c.parent) self.assertEqual([a,b,c], list(g.children)) self.assertUnstyledHTMLLike(grid_of_text_xml(['a','b'],['c',None]), g)
def test_set_n_rows(self): a, b, c, d = Text('a'), Text('b'), Text('c'), Text('d') g = Grid([[a, b], [c, d]]) g.n_rows = 1 self.assertEqual(g, a.parent) self.assertEqual(g, b.parent) self.assertIsNone(c.parent) self.assertIsNone(d.parent) self.assertEqual([a, b], list(g.children)) self.assertEqual(1, g.n_rows) with self.assertRaises(IndexError): g[1, 0] self.assertUnstyledHTMLLike(grid_of_text_xml(['a', 'b']), g) g.n_rows = 2 self.assertIsNone(g[1, 0]) self.assertEqual([a, b], list(g.children)) g[1, 0] = c self.assertEqual(g, c.parent) self.assertEqual([a, b, c], list(g.children)) self.assertUnstyledHTMLLike(grid_of_text_xml(['a', 'b'], ['c', None]), g)
def test_set_n_rows_to_0(self): g = Grid(n_rows=2, n_columns=1) g.n_rows = 0 self.assertUnstyledHTMLLike('<table></table>', g) g.n_rows = 1 self.assertUnstyledHTMLLike('<table><tr><td /></tr></table>', g)