-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tests): automatic submodule init
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
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
""" | ||
Compatibility suite tests. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |