File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change 1- import os
21import logging
2+ import os
33from typing import Callable
44from unittest import mock
5+
56import pytest
67
78from pip ._internal .cli .base_command import Command
@@ -171,13 +172,13 @@ def test_handle_pip_version_check_warning_includes_reason(
171172 options .disable_pip_version_check = False
172173 options .no_index = False
173174
174- dummy_session = mock .MagicMock ()
175- dummy_session . __enter__ . return_value = dummy_session
176- dummy_session . __exit__ . return_value = None
177- cmd . _build_session = mock . Mock ( return_value = dummy_session )
178-
179- with caplog .at_level (logging .WARNING ):
180- cmd .handle_pip_version_check (options )
175+ with mock .patch . object (
176+ cmd ,
177+ "_build_session" ,
178+ side_effect = PermissionError ( "Access is denied" ),
179+ ):
180+ with caplog .at_level (logging .WARNING ):
181+ cmd .handle_pip_version_check (options )
181182
182183 assert "There was an error checking the latest version of pip." in caplog .text
183184 assert "PermissionError" in caplog .text
You can’t perform that action at this time.
0 commit comments