]> Repositories - Adafruit_Blinka-hackapet.git/blob - python/testing/mcp.py
Reimplementation of corresponding circuitpython version
[Adafruit_Blinka-hackapet.git] / python / testing / mcp.py
1 import unittest
2
3
4 class TestEnum(unittest.TestCase):
5
6     def setUp(self):
7         import mcp
8         class Cls(mcp.Enum):
9             pass
10         Cls.one = Cls()
11         Cls.two = Cls()
12         # class refs would be implicitly populated correctly in a real module
13         Cls.__module__ = "ho.hum"
14         Cls.__qualname__ = "Example"
15         self.Cls = Cls
16
17
18     def test_iteritems(self):
19         items = list(self.Cls.iteritems())
20         self.assertEqual( items, [("one",self.Cls.one),("two",self.Cls.two),])
21
22
23     def test_repr(self):
24         name = "one"
25         actual = repr(getattr(self.Cls, name))
26         expected = "{}.{}.{}".format(self.Cls.__module__, self.Cls.__qualname__, name)
27         self.assertEqual( actual, expected)
28
29
30     def test_str(self):
31         self.assertEqual(str(self.Cls.one), repr(self.Cls.one))