Skip to content

Commit

Permalink
test: add tests for __main__.py (#295)
Browse files Browse the repository at this point in the history
* umu_test: add tests for __main__.main

* umu_test: fix tests
  • Loading branch information
R1kaB3rN authored Nov 29, 2024
1 parent 7f3f601 commit c382bf8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions umu/umu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,32 @@ def tearDown(self):
if self.test_cache_home.exists():
rmtree(self.test_cache_home.as_posix())

def test_main_nomusl(self):
"""Test __main__.main to ensure an exit when on a musl-based system."""
os.environ["LD_LIBRARY_PATH"] = f"{os.environ['LD_LIBRARY_PATH']}:musl"
with (
patch.object(
__main__,
"parse_args",
return_value=["foo", "foo"],
),
self.assertRaises(SystemExit),
):
__main__.main()

def test_main_noroot(self):
"""Test __main__.main to ensure an exit when run as a privileged user."""
with (
patch.object(
__main__,
"parse_args",
return_value=["foo", "foo"],
),
self.assertRaises(SystemExit),
patch.object(os, "geteuid", return_value=0),
):
__main__.main()

def test_restore_umu_cb_false(self):
"""Test _restore_umu when the callback evaluates to False."""
mock_cb = Mock(return_value=False)
Expand Down

0 comments on commit c382bf8

Please sign in to comment.