-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate_spec.py
35 lines (30 loc) · 1.07 KB
/
template_spec.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
from filename import function
#the filename doesn't need the .py
#if you need to import a not .py that's beyond the scope of this
#alternative:
#import filename #But now you have to refer to it as filename.function() instead of function()
import unittest
#Test methods MUST start with test
class ChangeMeTests(unittest.TestCase):
def test_test_something(self):
"""Text"""
given = function(args)
expected = "change me"
self.assertEqual(given , expected)
# Common Unit Tests:
# assertEqual(a, b) > a == b
# assertNotEqual(a, b) > a != b
# assertTrue(x) > bool(x) is True
# assertFalse(x) > bool(x) is False
# assertIs(a, b) > a is b
# assertIsNot(a, b) > a is not b
# assertIsNone(x) > x is None
# assertIsNotNone(x) > x is not None
# assertIn(a, b) > a in b
# assertNotIn(a, b) > a not in b
# assertIsInstance(a, b) > isinstance(a, b)
# assertNotIsInstance(a, b) > not isinstance(a, b)
if __name__ == '__main__':
unittest.main()
#This tells the file to run a unittest method called main() that
#I assume runs all the tests we made if run directly.