kiwi-el8/test/unit/privileges_test.py
Marcus Schäfer f8bc05fd42
Refactor use of raises in unit tests
Use raises as context manager instead of a method decorator.
This clearly identifies which code part is expected to raise
an exception. Related to Issue #1128
2019-09-29 19:42:43 +02:00

20 lines
567 B
Python

from mock import patch
from pytest import raises
from kiwi.privileges import Privileges
from kiwi.exceptions import KiwiPrivilegesError
class TestPrivileges:
@patch('os.geteuid')
def test_check_for_root_permiossion_false(self, mock_euid):
mock_euid.return_value = 1
with raises(KiwiPrivilegesError):
Privileges.check_for_root_permissions()
@patch('os.geteuid')
def test_check_for_root_permiossion_true(self, mock_euid):
mock_euid.return_value = 0
assert Privileges.check_for_root_permissions() is True