This repository was archived by the owner on Apr 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_py_everything.py
More file actions
171 lines (142 loc) · 5.36 KB
/
test_py_everything.py
File metadata and controls
171 lines (142 loc) · 5.36 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import sys, unittest # Do not remove or change this statement
sys.path.append("..") # Do not remove or change this statement
import py_everything as pye # Do not remove or change this statement
import py_everything.automation as pyeAuto # Do not remove or change this statement
import py_everything.dateUtils as pyeDate # Do not remove or change this statement
import py_everything.fileIO as pyeFileIO # Do not remove or change this statement
import py_everything.maths as pyeMaths # Do not remove or change this statement
import py_everything.error as pyeError # Do not remove or change this statement
import py_everything.search as pyeSearch # Do not remove or change this statement
import py_everything.web as pyeWeb # Do not remove or change this statement
import py_everything.htmlXml as pyeHtml # Do not remove or change this statement
import py_everything.mensuration as pyeMensuration # Do not remove or change this statement
import py_everything.conversion as pyeConversion # Do not remove or change this statement
import py_everything.roman as pyeRoman # Do not remove or change this statement
# Do not change the filename.
# Do not change the folder name.
# Add tests here and push or pull request to testthem on GitHub.
# Format:
# class TestPyEverything(unittest.TestCase):
# def test_[function_name]():
# code to test goes here
# example given below -
# assert py_everything.maths.add(2, 4) == 6
class TestPyEverything(unittest.TestCase):
def test_add(self):
assert pyeMaths.add(2, 4) == 6
def test_subtract(self):
assert pyeMaths.subtract(10, 5, 2) == 3
def test_multiply(self):
assert pyeMaths.multiply(5, 3, 2) == 30
def test_divide(self):
assert pyeMaths.divide(120, 10, "float") == 12.0
def test_divide_2(self):
assert pyeMaths.divide(120, 10, "int") == 12
def test_float_div(self):
assert pyeMaths.floatDiv(120, 10) == 12.0
def test_int_div(self):
assert pyeMaths.intDiv(120, 10) == 12
def test_mod(self):
assert pyeMaths.mod(123, 2) == 1
def test_eval_exp(self):
assert pyeMaths.evalExp("(2+3-1)*2") == 8
def test_avg(self):
assert pyeMaths.avg([2, 4, 6, 8]) == 5
def test_read_file(self):
assert pyeFileIO.readFile("read.txt") == "demo\n"
def test_write_file(self):
assert pyeFileIO.writeFile("write.txt", "demo data") is True
def test_clear_file(self):
assert pyeFileIO.clearFile("clear.txt") is True
def test_search_list(self):
listToTest = [
"py",
"pypi",
"anything",
"something",
"python",
"other",
"middlepy",
"notmatch",
"endpy",
]
assert pyeSearch.searchList(listToTest, "py") == [
"py",
"pypi",
"python",
"middlepy",
"endpy",
]
def test_search_list_2(self):
listToTest = [
"py",
"pypi",
"anything",
"something",
"python",
"other",
"middlepy",
"notmatch",
"endpy",
]
assert pyeSearch.searchList(listToTest, "py", filter="start") == [
"py",
"pypi",
"python",
]
def test_search_list_3(self):
listToTest = [
"py",
"pypi",
"anything",
"something",
"python",
"other",
"middlepy",
"notmatch",
"endpy",
]
assert pyeSearch.searchList(listToTest, "py", filter="end") == [
"py",
"middlepy",
"endpy",
]
def test_search_list_4(self):
listToTest = [
"py",
"pypi",
"anything",
"something",
"python",
"other",
"middlepy",
"notmatch",
"endpy",
]
assert pyeSearch.searchList(listToTest, "py", filter="exact") == ["py"]
def test_get_elements_by_id(self):
assert pyeHtml.getElementsById("app", "index.html") == [
(10, '<div id="app">something</div>'),
(10, '<div id="app">something</div>'),
(20, "<div id='app' class=\"app\">something</div>"),
]
def test_get_elements_by_class(self):
assert pyeHtml.getElementsByClass("app", "index.html") == [
(16, "<p class='app'>something</p>"),
(20, "<div id='app' class=\"app\">something</div>"),
(25, "<div class='app'>something</div>"),
]
def test_get_element_by_tag(self):
assert pyeHtml.getElementByTag("p", "index.html") == [(11, "<p>something</p>")]
def test_get_element_by_id(self):
assert pyeHtml.getElementById("app", "index.html") == [
(10, '<div id="app">something</div>')
]
def test_get_element_by_class(self):
assert pyeHtml.getElementByClass("app", "index.html") == [
(16, "<p class='app'>something</p>")
]
def test_convert_roman(self):
assert pyeRoman.convertRoman("MMXXI") == 2021
if __name__ == "__main__":
unittest.main()