Browse Source

Use unittest.mock instead of mock

The mock third party library was needed for mock support in py2
runtimes. Since we now only support py36 and later, we can use the
standard lib unittest.mock module instead.

Also enabled the hacking check that should have caught this, it
was missing from tox.ini along with most of the other in-tree
hacking checks we have added over the years.

Change-Id: Id91175d0db8b8edc72f0dd98925ddbf7415bb881
changes/42/734442/3
Hervé Beraud 1 year ago
committed by Sean McGinnis
parent
commit
3df1679658
4 changed files with 13 additions and 2 deletions
  1. +2
    -0
      HACKING.rst
  2. +0
    -1
      lower-constraints.txt
  3. +2
    -1
      neutron/tests/unit/common/ovn/test_utils.py
  4. +9
    -0
      tox.ini

+ 2
- 0
HACKING.rst View File

@ -26,6 +26,8 @@ Below you can find a list of checks specific to this repository.
- [N343] Production code must not import from neutron.tests.*
- [N344] Python 3: Do not use filter(lambda obj: test(obj), data). Replace it
with [obj for obj in data if test(obj)].
- [N346] Use neutron_lib.db.api.sqla_listen rather than sqlalchemy
- [N347] Test code must not import mock library
.. note::
When adding a new hacking check to this repository or ``neutron-lib``, make


+ 0
- 1
lower-constraints.txt View File

@ -44,7 +44,6 @@ logilab-common==1.4.1
logutils==0.3.5
Mako==0.4.0
MarkupSafe==1.0
mock==3.0.0
monotonic==0.6;python_version<'3.3'
mox3==0.20.0
msgpack-python==0.4.0


+ 2
- 1
neutron/tests/unit/common/ovn/test_utils.py View File

@ -13,8 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
import fixtures
import mock
from neutron_lib.api.definitions import extra_dhcp_opt as edo_ext
from neutron.common.ovn import constants


+ 9
- 0
tox.ini View File

@ -172,8 +172,17 @@ import-order-style = pep8
[flake8:local-plugins]
extension =
# Checks specific to neutron repo
N322 = neutron.hacking.checks:check_assert_called_once_with
N328 = neutron.hacking.checks:check_asserttruefalse
N330 = neutron.hacking.checks:check_assertempty
N331 = neutron.hacking.checks:check_assertisinstance
N332 = neutron.hacking.checks:check_assertequal_for_httpcode
N340 = neutron.hacking.checks:check_oslo_i18n_wrapper
N341 = neutron.hacking.checks:check_builtins_gettext
N343 = neutron.hacking.checks:check_no_imports_from_tests
N344 = neutron.hacking.checks:check_python3_no_filter
N346 = neutron.hacking.checks:check_no_sqlalchemy_event_import
N347 = neutron.hacking.checks:check_no_import_mock
# Checks from neutron-lib
N521 = neutron_lib.hacking.checks:use_jsonutils
N524 = neutron_lib.hacking.checks:check_no_contextlib_nested


Loading…
Cancel
Save