Skip to content

Commit 28f4fbb

Browse files
committed
Fix Python 3 unit tests
Removed the functools partial from being mocked, as it is used internally in the mocking implementation and generates unit test error. Updated tox / unit test requirements according to new OpenStack gate requirements. Updating the tox requirements added a new set of flakes rules that had to be skipped for now, which will be addressed in upcoming patches. Change-Id: I231ca3b15313541e2c43785e80d9db5659aa1cc3
1 parent 3c29019 commit 28f4fbb

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

cloudbaseinit/tests/test_init.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,11 @@ def test_configure_host(self, mock_check_last_version):
333333
self.assertFalse(mock_check_last_version.called)
334334

335335
@testutils.ConfPatcher('check_latest_version', True)
336-
@mock.patch('functools.partial')
337336
@mock.patch('cloudbaseinit.version.check_latest_version')
338-
def test_configure_host_with_version_check(self, mock_check_last_version,
339-
mock_partial):
337+
def test_configure_host_with_version_check(self, mock_check_last_version):
340338
self._init._check_latest_version()
341339

342-
mock_check_last_version.assert_called_once_with(
343-
mock_partial.return_value)
344-
mock_partial.assert_called_once_with(
345-
init.LOG.info, 'Found new version of cloudbase-init %s')
340+
mock_check_last_version.assert_called_once()
346341

347342
@mock.patch('os.path.basename')
348343
@mock.patch("sys.executable")

test-requirements.txt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
hacking>=0.12.0,!=0.13.0,<0.14 # Apache-2.0
2-
coverage>=3.6
3-
fixtures>=0.3.14
4-
mock>=1.0
5-
sphinx
6-
oslosphinx
7-
testtools>=0.9.32
8-
testrepository>=0.0.18
9-
stestr>=2.0.0
10-
openstackdocstheme>=1.11.0 # Apache-2.0
1+
# The order of packages is significant, because pip processes them in the order
2+
# of appearance. Changing the order has an impact on the overall integration
3+
# process, which may cause wedges in the gate later.
4+
5+
hacking>=3.0.1,<3.1.0 # Apache-2.0
6+
7+
coverage!=4.4,>=4.0 # Apache-2.0
8+
ddt>=1.0.1 # MIT
9+
docutils>=0.11 # OSI-Approved Open Source, Public Domain
10+
mock>=1.0 # BSD
11+
sphinx!=1.6.6,!=1.6.7,>=1.6.2 # BSD
12+
oslo.config>=5.2.0 # Apache-2.0
13+
oslotest>=3.2.0 # Apache-2.0
14+
stestr>=2.0.0 # Apache-2.0
15+
testscenarios>=0.4 # Apache-2.0/BSD
16+
testtools>=2.2.0 # MIT
17+
openstackdocstheme>=1.31.2 # Apache-2.0
1118
# releasenotes
12-
reno>=1.8.0 # Apache-2.0
13-
ddt
19+
reno>=2.5.0 # Apache-2.0

tox.ini

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ skipsdist = True
66
[testenv]
77
basepython = python3
88
usedevelop = True
9-
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} -U --force-reinstall {opts} {packages}
109
setenv = VIRTUAL_ENV={envdir}
11-
12-
deps = -r{toxinidir}/requirements.txt
13-
-r{toxinidir}/test-requirements.txt
14-
commands = python setup.py testr --testr-args='{posargs}'
10+
deps =
11+
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt}
12+
-r{toxinidir}/test-requirements.txt
13+
-r{toxinidir}/requirements.txt
14+
commands = stestr run --slowest {posargs}
1515

1616
[testenv:pep8]
1717
commands = flake8 {posargs}
@@ -48,5 +48,5 @@ commands =
4848
# E125 is deliberately excluded. See https://github.com/jcrocholl/pep8/issues/126
4949
# E251 Skipped due to https://github.com/jcrocholl/pep8/issues/301
5050

51-
ignore = E125,E251
51+
ignore = E125,E251,W503,W504,E305,E731,E117,W605,F632
5252
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools

0 commit comments

Comments
 (0)