John Vandenberg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/289894

Change subject: Use flake8-mock and fix mock.assert_called_once
......................................................................

Use flake8-mock and fix mock.assert_called_once

assert_called_once doesnt do anything.
assert_called_once_with is the correct function name,
but it is best avoided by using call_count.

Also enable flake8-mock, which flags this as M001.

Change-Id: I9f6e0c5c2b0f41b5b6d4cef33dcc3829b8dc1e05
---
M dev-requirements.txt
M tests/diff_tests.py
M tox.ini
3 files changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/94/289894/1

diff --git a/dev-requirements.txt b/dev-requirements.txt
index baed441..44499a0 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -17,6 +17,7 @@
 pyflakes>=0.9
 flake8
 flake8-docstrings>=0.2.6
+flake8-mock
 codecov
 coverage
 mock ; python_version < '3'
diff --git a/tests/diff_tests.py b/tests/diff_tests.py
index 402ad74..b94911f 100644
--- a/tests/diff_tests.py
+++ b/tests/diff_tests.py
@@ -94,7 +94,7 @@
 
 
 @patch('{0}.__import__'.format('__builtin__' if PY2 else 'builtins'),
-       side_effect=ImportError)
+       side_effect=ImportError, autospec=True)
 class TestNoBeautifulSoup(TestCase):
 
     """Test functions when BeautifulSoup is not installes."""
@@ -104,7 +104,7 @@
     def test_html_comparator(self, mocked_import):
         """Test html_comparator when bs4 not installed."""
         self.assertRaises(ImportError, html_comparator, '')
-        mocked_import.assert_called_once()
+        self.assertEqual(mocked_import.call_count, 1)
         self.assertIn('bs4', mocked_import.call_args[0])
 
 
diff --git a/tox.ini b/tox.ini
index 040e501..ea79390 100644
--- a/tox.ini
+++ b/tox.ini
@@ -38,6 +38,7 @@
        flake8-import-order
        flake8-tuple>=0.2.8
        flake8-print>=2.0.1
+       flake8-mock
 
 [testenv:flake8-py3]
 commands =

-- 
To view, visit https://gerrit.wikimedia.org/r/289894
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9f6e0c5c2b0f41b5b6d4cef33dcc3829b8dc1e05
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jay...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to