mirror of
https://github.com/senju1337/senju.git
synced 2025-12-24 07:39:29 +00:00
test: add first basic tests
This commit is contained in:
parent
101813b4f7
commit
6873428933
2 changed files with 36 additions and 0 deletions
11
tests/conftest.py
Normal file
11
tests/conftest.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import tempfile
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def temp_data_dir():
|
||||||
|
"""Create a temporary directory for test data"""
|
||||||
|
return Path(tempfile.mkdtemp())
|
||||||
|
|
||||||
25
tests/test_tests.py
Normal file
25
tests/test_tests.py
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# I do not trust python and it's tests, so I'm testing them. May not be worth much, but at least it shows me a few things.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import pytest # noqa: F401 do not remove this import. This is needed for pytest fixtures to work
|
||||||
|
|
||||||
|
import senju # noqa: F401
|
||||||
|
|
||||||
|
# Note: these weird arguments are an indicator of what should be dome before. For example,
|
||||||
|
# `temp_data_dir` is a function in `conftest.py`. If we put it in the arguments, it seems
|
||||||
|
# to run before our test, and the return value becomes a local.
|
||||||
|
#
|
||||||
|
# This is all very confusing for someone used to Rust's libtest
|
||||||
|
|
||||||
|
|
||||||
|
def test_tests_are_loaded():
|
||||||
|
assert True # if we make it here, they are
|
||||||
|
|
||||||
|
|
||||||
|
def test_temp_data_dir(temp_data_dir):
|
||||||
|
print(temp_data_dir)
|
||||||
|
testpath = temp_data_dir / "__test"
|
||||||
|
with open(testpath, "w") as f:
|
||||||
|
f.write("that dir actually works")
|
||||||
|
os.remove(testpath)
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue