Skip to content

Commit

Permalink
Remove assert_not_called
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle Fazzari <[email protected]>
  • Loading branch information
kyrofa committed Apr 23, 2020
1 parent 4ce72dd commit ffd89d0
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@

class TestBase(unittest.TestCase):

@mock.patch('vcstool.clients.vcs_base.urlopen')
@mock.patch('vcstool.clients.vcs_base._netrc_open')
@mock.patch('vcstool.clients.vcs_base.urlopen', autospec=True)
@mock.patch('vcstool.clients.vcs_base._netrc_open', autospec=True)
def test_load_url_calls_urlopen(self, netrc_open_mock, urlopen_mock):
urlopen_read_mock = urlopen_mock.return_value.read

vcs_base.load_url('example.com', timeout=123)

urlopen_mock.assert_called_once_with('example.com', timeout=123)
urlopen_read_mock.assert_called_once_with()
netrc_open_mock.assert_not_called()
self.assertFalse(netrc_open_mock.mock_calls)

@mock.patch('vcstool.clients.vcs_base.urlopen')
@mock.patch('vcstool.clients.vcs_base._netrc_open')
@mock.patch('vcstool.clients.vcs_base.urlopen', autospec=True)
@mock.patch('vcstool.clients.vcs_base._netrc_open', autospec=True)
def test_load_url_calls_netrc_open(self, netrc_open_mock, urlopen_mock):
for code in (401, 404):
urlopen_mock.side_effect = HTTPError(None, code, None, None, None)
Expand All @@ -40,7 +40,7 @@ def test_load_url_calls_netrc_open(self, netrc_open_mock, urlopen_mock):
vcs_base.load_url('example.com', timeout=123)

urlopen_mock.assert_called_once_with('example.com', timeout=123)
urlopen_read_mock.assert_not_called()
self.assertFalse(urlopen_read_mock.mock_calls)

netrc_open_mock.assert_called_once_with('example.com', timeout=123)

Expand All @@ -55,8 +55,8 @@ def test_netrc_open_no_such_file(self):
self.fail(
'The lack of a .netrc file should not result in an exception')

@mock.patch('vcstool.clients.vcs_base.urlopen')
@mock.patch('vcstool.clients.vcs_base.build_opener')
@mock.patch('vcstool.clients.vcs_base.urlopen', autospec=True)
@mock.patch('vcstool.clients.vcs_base.build_opener', autospec=True)
def test_netrc_open_basic_auth(self, build_opener_mock, urlopen_mock):
open_mock = build_opener_mock.return_value.open

Expand All @@ -74,7 +74,7 @@ def test_netrc_open_basic_auth(self, build_opener_mock, urlopen_mock):
finally:
shutil.rmtree(tmpdir)

urlopen_mock.assert_not_called()
self.assertFalse(urlopen_mock.mock_calls)

class _HTTPBasicAuthHandlerMatcher(object):
def __init__(self, test):
Expand All @@ -91,8 +91,8 @@ def __eq__(self, other):
_HTTPBasicAuthHandlerMatcher(self))
open_mock.assert_called_once_with(url, timeout=123)

@mock.patch('vcstool.clients.vcs_base.urlopen')
@mock.patch('vcstool.clients.vcs_base.build_opener')
@mock.patch('vcstool.clients.vcs_base.urlopen', autospec=True)
@mock.patch('vcstool.clients.vcs_base.build_opener', autospec=True)
def test_netrc_open_token_auth(self, build_opener_mock, urlopen_mock):
tmpdir = tempfile.mkdtemp()
netrc_file = os.path.join(tmpdir, 'netrc')
Expand All @@ -107,7 +107,7 @@ def test_netrc_open_token_auth(self, build_opener_mock, urlopen_mock):
finally:
shutil.rmtree(tmpdir)

build_opener_mock.assert_not_called()
self.assertFalse(build_opener_mock.mock_calls)

class _RequestMatcher(object):
def __init__(self, test):
Expand Down

0 comments on commit ffd89d0

Please sign in to comment.