Skip to content

Commit f5278fb

Browse files
Add test cases for fs operations
1 parent 72c69bd commit f5278fb

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ dev = [
5656
"coverage>=7.9.1,<8",
5757
"jestspectation>=1.4.5,<2",
5858
"types-aiofiles>=24.1.0.20250708,<26",
59+
"pytest-asyncio>=1.2.0",
5960
]
6061

6162
[build-system]

tests/actions/fs_test.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""
2+
tests / actions / fs_test.py
3+
4+
Test cases for file system operations
5+
"""
6+
7+
import pytest
8+
9+
from markten import ActionSession
10+
from markten.actions import fs
11+
12+
13+
@pytest.mark.asyncio
14+
async def test_read_write_file():
15+
action = ActionSession("test")
16+
dir = await fs.temp_dir(action)
17+
18+
await fs.write_file(action, dir / "file", "Some text")
19+
20+
assert await fs.read_file(action, dir / "file") == "Some text"
21+
22+
23+
@pytest.mark.asyncio
24+
async def test_cannot_overwrite_file():
25+
action = ActionSession("test")
26+
dir = await fs.temp_dir(action)
27+
28+
await fs.write_file(action, dir / "file", "Some text")
29+
30+
with pytest.raises(FileExistsError):
31+
await fs.write_file(action, dir / "file", "Some text")
32+
33+
34+
@pytest.mark.asyncio
35+
async def test_force_overwrite_file():
36+
action = ActionSession("test")
37+
dir = await fs.temp_dir(action)
38+
39+
await fs.write_file(action, dir / "file", "Some text")
40+
41+
await fs.write_file(action, dir / "file", "Some text", overwrite=True)

uv.lock

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)