-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest_named_constants.py
46 lines (34 loc) · 972 Bytes
/
test_named_constants.py
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
45
46
from named_constants import Constants
class MyConstants(Constants):
pi = 3.141592653589793
e = 2.718281828459045
answer = 42
BOILERPLATE = "This code comes with no warranty."
EURO_SYMBOL = u'\u20ac'
class Colors(Constants):
red, yellow, green, blue, white = range(5)
class FigConstants(Constants):
@classmethod
def read(cls, i):
return cls(int(i))
def other(self):
return "test method"
class ObjectType(FigConstants):
CustomColor = 0
Ellipse = 1
Polygon = 2
Spline = 3
Text = 4
Arc = 5
CompoundBegin = 6
CompoundEnd = -6
import doctest
def test_README():
failure_count, test_count = doctest.testfile('README.rst', verbose = True)
assert test_count > 0
assert failure_count == 0
def test_Colors():
assert Colors.green == 2
def test_ObjectType():
assert 'read' not in ObjectType
assert 'other' not in ObjectType