Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ jobs:
- name: Unit tests
id: unit
continue-on-error: true
env:
# Lists the slowest tests at the end of the log.
PYTEST_ADDOPTS: --durations=25
# Keeps pytest's temporary files in memory instead of on the runner's disk.
TMPDIR: /dev/shm
run: make test-unit
# Both steps above run to completion even when one fails, so the report lists every outcome
# instead of stopping at the first.
Expand All @@ -76,6 +81,11 @@ jobs:
- name: Test with pytest (Python 3.13)
id: pytest
continue-on-error: true
env:
# Lists the slowest tests at the end of the log.
PYTEST_ADDOPTS: --durations=25
# Keeps pytest's temporary files in memory instead of on the runner's disk.
TMPDIR: /dev/shm
run: make test
- name: Test connectors in per-connector environments
# Each connector's tests and type-check run in an environment built from its own
Expand Down Expand Up @@ -113,6 +123,11 @@ jobs:
- name: Install dependencies
run: make sync
- name: Test with pytest (Python 3.11)
env:
# Lists the slowest tests at the end of the log.
PYTEST_ADDOPTS: --durations=25
# Keeps pytest's temporary files in memory instead of on the runner's disk.
TMPDIR: /dev/shm
run: make test

# The ruleset on main requires one status check context named exactly `check`, and a check run
Expand Down
18 changes: 18 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Give each test an empty TimeNet store, registry and cache."""

import os
from pathlib import Path
import uuid

import pytest

Expand All @@ -20,3 +22,19 @@ def _timenet_state(tmp_path_factory, monkeypatch):
monkeypatch.setenv("TIMENET_LOCAL_REGISTRY", str(root / "store"))
monkeypatch.setenv("TIMENET_REMOTE_REGISTRY", str(root / "remote"))
monkeypatch.setenv("TIMENET_CACHE", str(root / "cache"))


@pytest.fixture
def tmp_path(tmp_path: Path) -> Path:
"""Give each test a folder that no other test of the run uses.

pytest deletes the folder of a passing test (``tmp_path_retention_policy``) and then gives its
name to the next test with the same name prefix. A file that the earlier test left open would
then be found at the later test's path.

Returns:
An empty folder inside pytest's own ``tmp_path``, which pytest deletes after the test.
"""
path = tmp_path / uuid.uuid4().hex[:8]
path.mkdir()
return path
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ markers = [
"value_dtypes: scalar value-dtype round-trip tests (run with '-m value_dtypes')",
"real_provenance: read the real commit of every install type instead of the stub in packages/conftest.py",
]
# Remove the tmp_path folder of a test that passed when the test ends. A full run writes about 7.5 GB.
tmp_path_retention_policy = "failed"

[tool.ty.src]
# Local git worktrees carry their own (possibly unrelated) copies of the code.
Expand Down