Пример #1
0
 def test_override_default_repr_of_BTree(self):
     # The pure-python implementation of BTrees (and buckets, and sets)
     # helpfully overrides __repr__ to drop the Py suffix from class names.
     self.assertEqual(
         GenericValue(OOBTree()).render(),
         '<BTrees.OOBTree.OOBTree with oid None>'
         ' (0 items)')
Пример #2
0
 def test_srsly_no_crashes(self):
     self.assertEqual(
         GenericValue(ExplodingClassNameRepr()).render(),
         '<unrepresentable>')
Пример #3
0
 def test_no_crashes(self):
     self.assertEqual(
         GenericValue(ExplodingRepr()).render(),
         '<unrepresentable ExplodingRepr>')
Пример #4
0
 def test_conteinerish_things_do_not_explode(self):
     self.assertEqual(
         GenericValue(ExplodingLen()).render(), '<ExplodingLen>')
Пример #5
0
 def test_override_default_repr_of_Persistent(self):
     # https://bugs.launchpad.net/zodbbrowser/+bug/1087138
     self.assertEqual(
         GenericValue(PersistentFrobNoRepr()).render(),
         '<zodbbrowser.tests.test_value.PersistentFrobNoRepr'
         ' with oid 0x17>')
Пример #6
0
 def test_conteinerish_things(self):
     self.assertEqual(
         GenericValue([1, 2, 3]).render(), "[1, 2, 3] (3 items)")
     self.assertEqual(GenericValue([1]).render(), "[1] (1 item)")
     self.assertEqual(GenericValue([]).render(), "[] (0 items)")
Пример #7
0
 def test_conteinerish_things_and_truncation(self):
     self.assertEqual(
         GenericValue([1, 2, 3]).render(limit=3),
         '[1,<span id="tr1" class="truncated">...</span> (3 items)')
Пример #8
0
 def test_truncation(self):
     self.assertEqual(
         GenericValue('a very long string').render(limit=10),
         """'a very lo<span id="tr1" class="truncated">...</span>""")
     self.assertEqual(TRUNCATIONS['tr1'], "ng string'")
     self.assertEqual(list(TRUNCATIONS_IN_ORDER), ['tr1'])
Пример #9
0
 def test_html_quoting(self):
     self.assertEqual(GenericValue('<html>').render(), "'&lt;html&gt;'")
Пример #10
0
 def test_no_dunder_repr(self):
     # Fixes https://github.com/mgedmin/zodbbrowser/issues/6
     obj = OldStyle()
     self.assertEqual(GenericValue(obj)._repr(), repr(obj))
Пример #11
0
 def test_simple_repr(self):
     for s in [None, '', 'xyzzy', b'\x17', u'\u1234']:
         self.assertEqual(GenericValue(s).render(), repr(s))
Пример #12
0
 def test_interface_compliance(self):
     verifyObject(IValueRenderer, GenericValue(None))