Coverage for tests/test_utilities.py: 100%
16 statements
« prev ^ index » next coverage.py v7.17.0, created at 2026-10-30 18:01 +0000
« prev ^ index » next coverage.py v7.17.0, created at 2026-10-30 18:01 +0000
1"""Tests of crimepy's shared tools.
3Contents:
4 test_another_data_folder_can_be_named: checks the other data folders.
5 test_the_data_folder_is_in_the_workspace: checks the default data folder.
7"""
9from __future__ import annotations
11import pathlib
13import pytest
15from crimepy import options, utilities
17""" Tests """
20def test_the_data_folder_is_in_the_workspace(tmp_path: pathlib.Path) -> None:
21 """Checks that the data folder is the "crime" folder of amos's workspace.
23 Args:
24 tmp_path: the test's temporary folder, which is amos's workspace
25 (see the "workspace" fixture).
27 """
28 folder = utilities.data_folder()
29 assert folder == tmp_path / 'data' / 'crime'
30 assert folder.is_dir()
33def test_another_data_folder_can_be_named(
34 tmp_path: pathlib.Path,
35 monkeypatch: pytest.MonkeyPatch) -> None:
36 """Checks that a folder argument and the options name other folders.
38 Args:
39 tmp_path: the test's temporary folder.
40 monkeypatch: sets the options for the test.
42 """
43 assert utilities.data_folder(tmp_path / 'given') == tmp_path / 'given'
44 monkeypatch.setattr(options, 'DATA_FOLDER', tmp_path / 'chosen')
45 assert utilities.data_folder() == tmp_path / 'chosen'
46 monkeypatch.setattr(options, 'DATA_FOLDER', None)
47 monkeypatch.setattr(options, 'DATA_SUBFOLDER', 'records')
48 assert utilities.data_folder() == tmp_path / 'data' / 'records'