Skip to content

Commit 84b6771

Browse files
Merge pull request #1436 from vojtechtrefny/main_coverage-open-fix
tests: Do not patch builtins.open directly
2 parents e4a2e7e + 843596d commit 84b6771

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/unit_tests/devicelibs_test/lvm_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@ class LVMTestCase(unittest.TestCase):
99
def test_lvm_autoactivation(self):
1010
localconf = "global { event_activation = 0 }"
1111

12-
with patch("builtins.open", mock_open(read_data=localconf)):
12+
with patch("blivet.devicelibs.lvm.open", mock_open(read_data=localconf)):
1313
# already disabled
1414
with self.assertRaises(RuntimeError):
1515
lvm.disable_lvm_autoactivation()
1616

1717
localconf = ""
18-
with patch("builtins.open", mock_open(read_data=localconf)) as m:
18+
with patch("blivet.devicelibs.lvm.open", mock_open(read_data=localconf)) as m:
1919
lvm.disable_lvm_autoactivation()
2020
m.assert_called_with("/etc/lvm/lvmlocal.conf", "a")
2121
handle = m()
2222
handle.write.assert_called_once_with("global { event_activation = 0 }")
2323

2424
localconf = "test\ntest"
25-
with patch("builtins.open", mock_open(read_data=localconf)) as m:
25+
with patch("blivet.devicelibs.lvm.open", mock_open(read_data=localconf)) as m:
2626
# not disabled
2727
with self.assertRaises(RuntimeError):
2828
lvm.reenable_lvm_autoactivation()
2929

3030
localconf = "# global { event_activation = 0 }"
31-
with patch("builtins.open", mock_open(read_data=localconf)) as m:
31+
with patch("blivet.devicelibs.lvm.open", mock_open(read_data=localconf)) as m:
3232
# not disabled
3333
with self.assertRaises(RuntimeError):
3434
lvm.reenable_lvm_autoactivation()
3535

3636
localconf = "test\nglobal { event_activation = 0 }"
37-
with patch("builtins.open", mock_open(read_data=localconf)) as m:
37+
with patch("blivet.devicelibs.lvm.open", mock_open(read_data=localconf)) as m:
3838
lvm.reenable_lvm_autoactivation()
3939
m.assert_called_with("/etc/lvm/lvmlocal.conf", "w+")
4040
handle = m()

0 commit comments

Comments
 (0)