2022-04-14 09:17:18 -04:00
|
|
|
import os
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2024-12-28 01:01:05 -05:00
|
|
|
def test_success(root: str) -> None:
|
2022-04-14 09:17:18 -04:00
|
|
|
path = os.path.join(root, "abc.txt")
|
2024-12-28 01:01:05 -05:00
|
|
|
with open(path, "w") as f:
|
2022-04-14 09:17:18 -04:00
|
|
|
f.write("hello")
|
2024-12-28 01:01:05 -05:00
|
|
|
with open(path) as f:
|
2022-04-14 09:17:18 -04:00
|
|
|
assert f.read() == "hello"
|
|
|
|
|
|
|
|
|
2024-12-28 01:01:05 -05:00
|
|
|
def test_failure() -> None:
|
2022-04-14 09:17:18 -04:00
|
|
|
with pytest.raises(AssertionError):
|
2024-12-28 01:01:05 -05:00
|
|
|
open("abc.txt", "w") # noqa: SIM115
|
2022-04-14 09:17:18 -04:00
|
|
|
|
|
|
|
with pytest.raises(AssertionError):
|
2024-12-28 01:01:05 -05:00
|
|
|
open(file="abc.txt", mode="w") # noqa: SIM115
|
2022-04-14 09:17:18 -04:00
|
|
|
|
|
|
|
with pytest.raises(AssertionError):
|
|
|
|
os.mkdir("a")
|
|
|
|
|
|
|
|
with pytest.raises(AssertionError):
|
|
|
|
os.mkdir(path="a")
|