From 1fe416318d7905856e76151065cd1b495a15ff31 Mon Sep 17 00:00:00 2001 From: Olivier Ramonat Date: Tue, 26 Mar 2024 14:02:13 +0100 Subject: [PATCH 1/2] Do not use assert to skip a test but rely on skipif() Otherwise, we get an error when running the testsuite. Also adjust pytest.mark.skipif to enable test_rlimit_foreground_option on macOS. --- tests/tests_e3/os/process/main_test.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/tests_e3/os/process/main_test.py b/tests/tests_e3/os/process/main_test.py index e9168868..b6b2ecce 100644 --- a/tests/tests_e3/os/process/main_test.py +++ b/tests/tests_e3/os/process/main_test.py @@ -120,7 +120,7 @@ def run_test(): e.restore() -@pytest.mark.skipif(sys.platform == "win32", reason="A linux test") +@pytest.mark.skipif(sys.platform == "win32", reason="A linux/macOS test") def test_rlimit_ctrl_c(): """Test rlimit CTRL-C. @@ -164,9 +164,6 @@ def test_rlimit_ctrl_c(): except ImportError: raise ImportError("ptyprocess is needed to run this tests") from None - # Only a linux test - assert sys.platform.startswith("linux"), "This test make sens only on linux" - script_to_run = """ from __future__ import annotations @@ -193,7 +190,7 @@ def test_rlimit_ctrl_c(): assert int(end - start) < 30, f"CTRL-C failed: take {int(end - start)} seconds" -@pytest.mark.skipif(sys.platform == "win32", reason="A linux test") +@pytest.mark.skipif(sys.platform != "linux", reason="A linux test") def test_rlimit_foreground_option(): """Test rlimit --foreground. @@ -204,9 +201,6 @@ def test_rlimit_foreground_option(): except ImportError: raise ImportError("ptyprocess is needed to run this tests") from None - # Only a linux test - assert sys.platform.startswith("linux"), "This test make sens only on linux" - # Test with --foreground os.environ["PS1"] = "$ " # Use TERM=dummy to avoid prompt coloring to interfere with the result From cd79be8ddb7432d4926756a05455d52153b26e5b Mon Sep 17 00:00:00 2001 From: Olivier Ramonat Date: Tue, 26 Mar 2024 14:05:49 +0100 Subject: [PATCH 2/2] Do not assume Git default branch is called "master" Running git init won't always create a "master" branch. More and more configurations creates a branch named "main", and the name of the initial branch can be changed using: [init] defaultBranch = nameofbranch To get the first branch created by git init, run: git branch --show-current --- tests/tests_e3/vcs/git/main_test.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/tests_e3/vcs/git/main_test.py b/tests/tests_e3/vcs/git/main_test.py index cc143c1e..4df562ce 100644 --- a/tests/tests_e3/vcs/git/main_test.py +++ b/tests/tests_e3/vcs/git/main_test.py @@ -69,6 +69,9 @@ def test_git_repo(): repo.git_cmd(["config", "user.email", "e3-core@example.net"]) repo.git_cmd(["config", "user.name", "e3 core"]) repo.git_cmd(["commit", "-m", "new file"]) + + main_branch = repo.git_cmd(["branch", "--show-current"]).out + repo.git_cmd(["tag", "-a", "-m", "new tag", "20.0855369232"]) repo.git_cmd(["notes", "--ref", "review", "add", "HEAD", "-F", commit_note]) @@ -130,7 +133,7 @@ def test_git_repo(): repo2 = GitRepository(working_tree2) giturl = "file://%s" % working_tree.replace("\\", "/") repo2.init(url=giturl, remote="tree1") - repo2.update(url=giturl, refspec="master") + repo2.update(url=giturl, refspec=main_branch) assert repo2.rev_parse() == repo.rev_parse() repo2.fetch_gerrit_notes(url=giturl)