blob: ced405ed9e6a895b1eb2c5e716152188306fb1ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
from chrysacase import ChrysalideTestCase
from gi.repository import GObject
from pychrysalide.glibext import StringBuilder
class TestStringBuilder(ChrysalideTestCase):
"""Test cases for pychrysalide.glibext.StringBuilder."""
def testStringBuilderCreation(self):
"""Create objects with StringBuilder interface."""
with self.assertRaisesRegex(NotImplementedError, 'StringBuilder can not be constructed'):
sc = StringBuilder()
class NewStringBuilderImplem(GObject.Object, StringBuilder):
pass
nsi = NewStringBuilderImplem()
self.assertIsNotNone(nsi)
def testStringBuilderMethods(self):
"""Test the StringBuilder methods."""
class BasicStringBuilderImplem(GObject.Object, StringBuilder):
def __init__(self, desc):
super().__init__()
self._desc = desc
def _to_string(self, flags=0):
return self._desc
desc = 'simple_desc'
sb = BasicStringBuilderImplem(desc)
self.assertEqual(sb.to_string(), desc)
self.assertEqual(str(sb), desc)
self.assertEqual(f'{sb}', desc)
|