-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnitTest_TimeSoft.py
52 lines (43 loc) · 2.47 KB
/
UnitTest_TimeSoft.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
47
48
49
50
51
52
# Importing unittest to test InputCheck class.
import unittest
# Also, importing InputCheck class as itself.
from timeSoft_test import InputCheck
class TestInputCheck(unittest.TestCase):
"""This class implements testing of InputCheck class from timeSoft.py file."""
def setUp(self):
# Setting up a reference to a InputCheck class.
# In the next methods, using indexing for returning boolean type only.
self.check = InputCheck
def test_email_InputCheck(self):
# Cheking if check_email() returns True when it takes a correct arg.
self.assertTrue(self.check('[email protected]').check_email())
# Making a few various tests:
# Checking if check_email() returns False when it takes a incorrect args.
self.assertFalse(self.check('tlastivka@@ex.ua').check_email()[0])
self.assertFalse(self.check('[email protected]').check_email()[0])
self.assertFalse(self.check('tlastivka/@ex.ua').check_email()[0])
self.assertFalse(self.check('[email protected]').check_email()[0])
def test_incorrect_InputCheck(self):
# Cheking if check_incorrect_vals() returns True when it takes a correct arg.
self.assertTrue(self.check('Hello World').check_incorrect_vals())
# Making a few various tests:
# Cheking if check_incorrect_vals() returns False when it takes a incorrect args.
self.assertFalse(self.check(',').check_incorrect_vals()[0])
self.assertFalse(self.check('\\').check_incorrect_vals()[0])
self.assertFalse(self.check('/').check_incorrect_vals()[0])
self.assertFalse(self.check('"').check_incorrect_vals()[0])
def test_spaces_tabs_InputCheck(self):
# Cheking if check_spaces_tabs() returns True when it takes a correct arg.
self.assertTrue(self.check('HelloWorld').check_spaces_tabs())
# Making a few various tests:
# Cheking if check_spaces_tabs() returns False when it takes a incorrect args.
self.assertFalse(self.check(' ').check_spaces_tabs()[0])
self.assertFalse(self.check(' ').check_spaces_tabs()[0])
def test_number_only_InputCheck(self):
# Cheking if number_only() returns True when it takes a correct arg.
self.assertTrue(self.check('0').number_only())
# Making a few various tests:
# Cheking if number_only() returns False when it takes a incorrect args.
self.assertFalse(self.check('Hello0World!').number_only()[0])
if __name__ == '__main__':
unittest.main()