Skip to content

Commit

Permalink
chore(tests): automatic submodule init
Browse files Browse the repository at this point in the history
In order to reduce the burden for new contributors, I have added a
pytest fixture which checks that the submodule has been created. If it
is not, it will try and run `git submodule init`.

Signed-off-by: JP-Ellis <[email protected]>
  • Loading branch information
JP-Ellis committed Nov 15, 2023
1 parent edd6856 commit 1763eb3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/v3/compatibility-suite/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Compatibility suite tests.
"""
30 changes: 30 additions & 0 deletions tests/v3/compatibility-suite/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Pytest configuration.
As the compatibility suite makes use of a submodule, we need to make sure the
submodule has been initialized before running the tests.
"""

import shutil
import subprocess
from pathlib import Path

import pytest


@pytest.fixture(scope="session", autouse=True)
def _submodule_init() -> None:
"""Initialize the submodule."""
# Locate the git execute
submodule_dir = Path(__file__).parent / "definition"
if submodule_dir.is_dir():
return

git_exec = shutil.which("git")
if git_exec is None:
msg = (
"Submodule not initialized and git executable not found."
" Please initialize the submodule with `git submodule init`."
)
raise RuntimeError(msg)
subprocess.check_call([git_exec, "submodule", "init"]) # noqa: S603

0 comments on commit 1763eb3

Please sign in to comment.