-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_get_file_content.py
More file actions
41 lines (27 loc) · 1.07 KB
/
Copy pathtest_get_file_content.py
File metadata and controls
41 lines (27 loc) · 1.07 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
from functions.get_file_content import get_file_content
from config import MAX_FILE_CHARS
def print_separator():
print("\n" + "=" * 50 + "\n")
if __name__ == "__main__":
# Test large file truncation
print("Testing lorem.txt truncation...")
lorem_result = get_file_content("calculator", "lorem.txt")
print(f"Length returned: {len(lorem_result)}")
print("Truncation message present:",
f'truncated at {MAX_FILE_CHARS}' in lorem_result)
print_separator()
# Test reading main.py
print("Testing main.py...")
print(get_file_content("calculator", "main.py"))
print_separator()
# Test reading nested file
print("Testing pkg/calculator.py...")
print(get_file_content("calculator", "pkg/calculator.py"))
print_separator()
# Should fail (outside working directory)
print("Testing /bin/cat...")
print(get_file_content("calculator", "/bin/cat"))
print_separator()
# Should fail (non-existent file)
print("Testing pkg/does_not_exist.py...")
print(get_file_content("calculator", "pkg/does_not_exist.py"))