HPI/tests/commits.py
Dima Gerasimov 64a4782f0e core/ci: fix windows-specific issues
- use portable separators
- paths should be prepended with r' (so backwards slash isn't treated as escaping)
- sqlite connections should be closed (otherwise windows fails to remove the underlying db file)
- workaround for emojis via PYTHONUTF8=1 test for now
- make ZipPath portable
- properly use tox python environment everywhere

  this was causing issues on Windows
  e.g.
      WARNING: test command found but not installed in testenv
        cmd: C:\hostedtoolcache\windows\Python\3.9.12\x64\python3.EXE
2022-05-03 10:16:01 +01:00

41 lines
1 KiB
Python

from pathlib import Path
from more_itertools import bucket
import pytest
import os
pytestmark = pytest.mark.skipif(
os.name == 'nt',
reason='TODO figure out how to install fd-find on Windows',
)
def test() -> None:
from my.coding.commits import commits
all_commits = list(commits())
assert len(all_commits) > 100
buckets = bucket(all_commits, key=lambda c: c.repo)
by_repo = {k: list(buckets[k]) for k in buckets}
# handle later
@pytest.fixture(autouse=True)
def prepare(tmp_path: Path):
# TODO maybe test against actual testdata, could check for
# - datetime handling
# - bare repos
# - canonical name
# - caching?
hpi_repo_root = Path(__file__).absolute().parent.parent
assert (hpi_repo_root / '.git').exists(), hpi_repo_root
class commits:
emails = {'karlicoss@gmail.com'}
names = {'Dima'}
roots = [hpi_repo_root]
from my.core.cfg import tmp_config
with tmp_config() as config:
config.commits = commits
yield