Skip to content

Commit c2c51e1

Browse files
committed
add read_files tests
1 parent 1a87eac commit c2c51e1

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test file content
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import pytest
2+
3+
from monitor_utils import read_file
4+
5+
6+
def test_read_file():
7+
"""'read_file' should open a file relative to the file where the function was called"""
8+
content = read_file("sample_file.txt")
9+
assert content == "Test file content\n"
10+
11+
12+
@pytest.mark.parametrize("mode", ["a", "w", "wb"])
13+
def test_read_file_invalid_mode(mode):
14+
"""'read_file' should raise a ValueError if an invalid mode is passed"""
15+
with pytest.raises(ValueError):
16+
read_file("sample_file.txt", mode=mode)

0 commit comments

Comments
 (0)