mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-14 03:39:53 +03:00
The `test_scm.py` and `test_api.py` tests did not configure a local git user and email, which caused some tests to fail (errors reproducible in rootbld, or in environments without a global git config). Configure an example git user so tests can be completed. Example error: ``` ERROR at setup of test__get_version_from_scm__returns_tag_if_method_unspecified[git] _ request = <SubRequest 'scm' for <Function test__get_version_from_scm__returns_tag_if_method_unspecified[git]>> scm_dir = PosixPath('/tmp/tmp3dzww1_2') @pytest.fixture(params=["git", "hg"]) def scm(request: pytest.FixtureRequest, scm_dir: Path) -> Scm: scm = cast(Scm, request.getfixturevalue(request.param)) file_path = scm_dir / "test.txt" with open(file_path, "w") as f: f.write("a\n") > scm.commit("Add a", [file_path]) tests/pdm/backend/hooks/version/test_scm.py:197: [...] input = None, capture_output = True, timeout = None, check = True popenargs = ([PosixPath('/usr/bin/git'), 'commit', '-m', 'Add a'],) kwargs = {'cwd': PosixPath('/tmp/tmp3dzww1_2'), 'encoding': 'utf-8', 'stderr': -1, 'stdout': -1} process = <Popen: returncode: 128 args: [PosixPath('/usr/bin/git'), 'commit', '-m', 'A...> stdout = '' stderr = 'Author identity unknown\n\n*** Please tell me who you are.\n\nRun\n\n git config --global user.email "you@example.co... only in this repository.\n\nfatal: unable to auto-detect email address (got \'buildozer@build-edge-x86_64.(none)\')\n' retcode = 128 ```
22 lines
997 B
Diff
22 lines
997 B
Diff
--- a/tests/conftest.py
|
|
+++ b/tests/conftest.py
|
|
@@ -23,6 +23,8 @@
|
|
@pytest.fixture
|
|
def scm(fixture_project: Path) -> None:
|
|
subprocess.check_call(["git", "init"])
|
|
+ subprocess.check_call(["git", "config", "--local", "user.name", "example"])
|
|
+ subprocess.check_call(["git", "config", "--local", "user.email", "example@example.com"])
|
|
subprocess.check_call(["git", "add", "."])
|
|
subprocess.check_call(["git", "commit", "-m", "initial commit"])
|
|
subprocess.check_call(["git", "tag", "-a", "0.1.0", "-m", "version 0.1.0"])
|
|
--- a/tests/pdm/backend/hooks/version/test_scm.py
|
|
+++ b/tests/pdm/backend/hooks/version/test_scm.py
|
|
@@ -126,6 +126,8 @@
|
|
def __init__(self, cmd: Path, cwd: Path) -> None:
|
|
super().__init__(cmd, cwd)
|
|
self.run("config", "commit.gpgsign", "false")
|
|
+ self.run("config", "--local", "user.name", "example")
|
|
+ self.run("config", "--local", "user.email", "example@example.com")
|
|
|
|
def _init(self):
|
|
self.run("init")
|