From 3db6366e84abf4824f6201b5d349c3251f07d408 Mon Sep 17 00:00:00 2001 From: Marcel Wilson Date: Thu, 11 Jan 2024 09:46:13 -0600 Subject: [PATCH] * PT019 --- tests/test_actions.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/test_actions.py b/tests/test_actions.py index 269cad1..743a4f4 100644 --- a/tests/test_actions.py +++ b/tests/test_actions.py @@ -1029,19 +1029,16 @@ def test_perform_save_console_log_writes_log( file_descriptor = mocked_open() file_descriptor.write.assert_called_once_with("\n".join(test_log)) - @mock.patch("builtins.open", new_callable=mock.mock_open) @mock.patch( "screenpy_selenium.actions.save_console_log.AttachTheFile", autospec=True ) - def test_sends_kwargs_to_attach( - self, mocked_atf: mock.Mock, _: mock.Mock, Tester: Actor - ) -> None: + def test_sends_kwargs_to_attach(self, mocked_atf: mock.Mock, Tester: Actor) -> None: test_path = "doppelganger.png" test_kwargs = {"name": "Mystique"} browser = get_mocked_browser(Tester) browser.get_log.return_value = [1, 2, 3] - - SaveConsoleLog(test_path).and_attach_it(**test_kwargs).perform_as(Tester) + with mock.patch("builtins.open", new_callable=mock.mock_open): + SaveConsoleLog(test_path).and_attach_it(**test_kwargs).perform_as(Tester) mocked_atf.assert_called_once_with(test_path, **test_kwargs) @@ -1095,17 +1092,17 @@ def test_perform_calls_open_with_path( mocked_open.assert_called_once_with(test_path, "wb+") - @mock.patch("builtins.open", new_callable=mock.mock_open) @mock.patch( "screenpy_selenium.actions.save_screenshot.AttachTheFile", autospec=True ) def test_perform_sends_kwargs_to_attach( - self, mocked_atf: mock.Mock, _: mock.Mock, Tester: Actor + self, mocked_atf: mock.Mock, Tester: Actor ) -> None: test_path = "souiiie.png" test_kwargs = {"color": "Red", "weather": "Tornado"} - SaveScreenshot(test_path).and_attach_it(**test_kwargs).perform_as(Tester) + with mock.patch("builtins.open", new_callable=mock.mock_open): + SaveScreenshot(test_path).and_attach_it(**test_kwargs).perform_as(Tester) mocked_atf.assert_called_once_with(test_path, **test_kwargs)