Пример #1
0
 def test_delete(self):
     c = Cell('!!n=v|', True)
     c.delete('n')
     self.assertEqual(c.string, '!!|')
     c = Cell('!!n=v1 m=w n="v2"|', True)
     c.delete('n')
     self.assertEqual(c.string, '!!m=w |')
     # Test removing a non-existing attribute
     c.delete('n')
Пример #2
0
 def test_cached_attrs_expiry(self):
     """_cached_attrs should expire when _cached_match is updated."""
     c = Cell('\n!v', True)
     # Fill _cached_attrs and _cached_match
     self.assertEqual(c.attrs, {})
     # Invalidate both caches
     c.insert(2, 'a|')
     # Update _cached_match
     self.assertEqual(c.value, 'v')
     # _cached_attrs should not be valid
     self.assertEqual(c.attrs, {'a': ''})
Пример #3
0
 def test_space_or_quote_at_set_boundary(self):
     c = Cell('!!n=v|', True)
     c.set('m', 'w')
     self.assertEqual(c.string, '!!n=v m="w"|')
     c = Cell('!! n=v |', True)
     c.set('m', 'w')
     self.assertEqual(c.string, '!! n=v m="w" |')
Пример #4
0
 def test_inline_cell_no_attr_span_set(self):
     c = Cell('!! 00', True)
     c.set('n', 'v')
     self.assertEqual(c.string, '!! n="v" | 00')
     c = Cell('!! 00', True)
     c.set('n', '')
     self.assertEqual(c.string, '!! n | 00')
Пример #5
0
 def test_set_overwrite(self):
     c = Cell('\n! n=v | 00', True)
     # Set a new value for an existing attribute
     c.set('n', 'w')
     # Set a new attribute
     c.set('n2', 'v2')
     self.assertEqual(c.string, '\n! n="w" n2="v2" | 00')
Пример #6
0
 def test_value(self):
     c = Cell('\n| a ')
     self.assertEqual(' a ', c.value)
     self.assertEqual(repr(c), 'Cell(\'\\n| a \')')
     self.assertEqual(c.attrs, {})
     # Use _cached_attrs
     self.assertEqual(c.attrs, {})
     # Inline _header cell
     c = Cell('|| 01 ', True)
     self.assertEqual(c.value, ' 01 ')
     # Inline non-_header cell
     c = Cell('|| 01 ', False)
     self.assertEqual(c.value, ' 01 ')
     # Set a new value
     c.value = '\na\na'
     self.assertEqual(c.value, '\na\na')
Пример #7
0
 def test_has_get(self):
     c = Cell('\n! n="v" | 00', True)
     self.assertTrue(c.has('n'))
     self.assertEqual(c.get('n'), 'v')