-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
64 lines (45 loc) · 1.5 KB
/
tests.py
File metadata and controls
64 lines (45 loc) · 1.5 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
from functions.get_files_info import get_files_info
from functions.get_file_content import get_file_content
from functions.write_file import write_file
from functions.run_python_file import run_python_file
# tests
def main():
# get file info
print(get_files_info("calculator", "."))
print()
print(get_files_info("calculator", "pkg"))
print()
print(get_files_info("calculator", "/bin"))
print()
print(get_files_info("calculator", "../"))
print("\n---\n")
# get file content
print(get_file_content("calculator", "main.py"))
print()
print(get_file_content("calculator", "pkg/calculator.py"))
print()
print(get_file_content("calculator", "/bin/cat"))
print()
print(get_file_content("calculator", "pkg/does_not_exist.py"))
print("\n---\n")
# writing files
print(write_file("calculator", "lorem.txt", "wait, this isn't lorem ipsum"))
print()
print(write_file("calculator", "pkg/morelorem.txt", "lorem ipsum dolor sit amet"))
print()
print(write_file("calculator", "/tmp/temp.txt", "this should not be allowed"))
print("\n---\n")
# run
print(run_python_file("calculator", "main.py"))
print()
print(run_python_file("calculator", "main.py", ["3 + 5"]))
print()
print(run_python_file("calculator", "tests.py"))
print()
print(run_python_file("calculator", "../main.py"))
print()
print(run_python_file("calculator", "nonexistent.py"))
print()
# main
if __name__ == "__main__":
main()