add PrefixIdentifier() and some tests
This commit is contained in:
parent
e5ca63953d
commit
8a16fe159f
6 changed files with 162 additions and 6 deletions
38
tests/test_strtools.py
Normal file
38
tests/test_strtools.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
|
||||
|
||||
import unittest
|
||||
|
||||
from suou.strtools import PrefixIdentifier
|
||||
|
||||
class TestStrtools(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
...
|
||||
|
||||
def tearDown(self) -> None:
|
||||
...
|
||||
|
||||
def test_PrefixIdentifier_empty(self):
|
||||
pi = PrefixIdentifier(None)
|
||||
self.assertEqual(pi.hello, 'hello')
|
||||
self.assertEqual(pi['with spaces'], 'with spaces')
|
||||
self.assertEqual(pi['\x1b\x00'], '\x1b\0')
|
||||
self.assertEqual(pi.same_thing, pi['same_thing'])
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
pi[0]
|
||||
|
||||
self.assertEqual(PrefixIdentifier(None), PrefixIdentifier(''))
|
||||
|
||||
def test_PrefixIdentifier_invalid(self):
|
||||
with self.assertRaises(TypeError):
|
||||
pi = PrefixIdentifier(1)
|
||||
pi.hello
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
PrefixIdentifier([99182])
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
PrefixIdentifier(b'alpha_')
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue