-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_get_file_content.py
More file actions
25 lines (20 loc) · 1.06 KB
/
Copy pathtest_get_file_content.py
File metadata and controls
25 lines (20 loc) · 1.06 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
from functions.get_file_content import get_file_content
# Test 1. Show the truncation message
lorem = get_file_content("calculator", "lorem.txt")
print(f"lorem.txt length: {len(lorem)}")
print(f"lorem.txt truncated: {'truncated' in lorem}")
# Note: The following tests are not checking the full content, just that the expected lines are present.
# The full content is not printed to avoid overwhelming the output.
# Test 2. Print snippet of main.py to show 'def main():'
main_content = get_file_content("calculator", "main.py")
target_line = "def main() -> None:"
if target_line in main_content:
print(f"Found: {target_line}")
# Test 3. Print the line for _apply_operator from calculator.py
calc_content = get_file_content("calculator", "pkg/calculator.py")
target = "def _apply_operator(self, operators: list[str], values: list[float]) -> None:"
if target in calc_content:
print(f"Found: {target}")
# Test 4. Print the error cases (these are short and required)
print(get_file_content("calculator", "/bin/cat"))
print(get_file_content("calculator", "pkg/does_not_exist.py"))