Beispiel #1
0
 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
Beispiel #2
0
 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
Beispiel #3
0
  def test_set_n_columns(self):
    a, b, c, d = Text('a'), Text('b'), Text('c'), Text('d')
    g = Grid([[a, b], [c, d]])

    g.n_columns = 1
    self.assertEqual(g, a.parent)
    self.assertEqual(g, c.parent)
    self.assertIsNone(b.parent)
    self.assertIsNone(d.parent)
    self.assertEqual([a,c], list(g.children))
    self.assertEqual(1, g.n_columns)
    with self.assertRaises(IndexError):
      g[0,1]
    self.assertUnstyledHTMLLike(grid_of_text_xml(['a'],['c']), g)

    g.n_columns = 2
    self.assertIsNone(g[0,1])
    self.assertEqual([a,c], list(g.children))
    g[0,1] = b
    self.assertEqual(g, b.parent)
    self.assertEqual([a,b,c], list(g.children))
    self.assertUnstyledHTMLLike(grid_of_text_xml(['a','b'], ['c', None]), g)
Beispiel #4
0
    def test_set_n_columns(self):
        a, b, c, d = Text('a'), Text('b'), Text('c'), Text('d')
        g = Grid([[a, b], [c, d]])

        g.n_columns = 1
        self.assertEqual(g, a.parent)
        self.assertEqual(g, c.parent)
        self.assertIsNone(b.parent)
        self.assertIsNone(d.parent)
        self.assertEqual([a, c], list(g.children))
        self.assertEqual(1, g.n_columns)
        with self.assertRaises(IndexError):
            g[0, 1]
        self.assertUnstyledHTMLLike(grid_of_text_xml(['a'], ['c']), g)

        g.n_columns = 2
        self.assertIsNone(g[0, 1])
        self.assertEqual([a, c], list(g.children))
        g[0, 1] = b
        self.assertEqual(g, b.parent)
        self.assertEqual([a, b, c], list(g.children))
        self.assertUnstyledHTMLLike(grid_of_text_xml(['a', 'b'], ['c', None]),
                                    g)
Beispiel #5
0
 def test_set_n_columns_to_0(self):
   g = Grid(n_rows=1, n_columns=2)
   g.n_columns = 0
   self.assertUnstyledHTMLLike('<table><tr></tr></table>', g)
   g.n_columns = 1
   self.assertUnstyledHTMLLike('<table><tr><td /></tr></table>', g)
Beispiel #6
0
 def test_set_n_columns_to_0(self):
     g = Grid(n_rows=1, n_columns=2)
     g.n_columns = 0
     self.assertUnstyledHTMLLike('<table><tr></tr></table>', g)
     g.n_columns = 1
     self.assertUnstyledHTMLLike('<table><tr><td /></tr></table>', g)