Add test for moxstubout
Add a test for moxstubout and update all of the python3-related bits needed so the tests will pass there. Those changes are based on Julien's work in https://review.openstack.org/#/c/55606 Change-Id: Ie7c41dbfbabfb3bcbd4e181b095aa2cf09345f5c
This commit is contained in:
parent
224b61f78c
commit
5f92f04e50
@ -0,0 +1,14 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
six.add_move(six.MovedModule('mox', 'mox', 'mox3.mox'))
|
@ -16,7 +16,8 @@
|
||||
# under the License.
|
||||
|
||||
import fixtures
|
||||
import mox
|
||||
|
||||
from six.moves import mox
|
||||
|
||||
|
||||
class MoxStubout(fixtures.Fixture):
|
||||
|
4
requirements-py3.txt
Normal file
4
requirements-py3.txt
Normal file
@ -0,0 +1,4 @@
|
||||
fixtures>=0.3.14
|
||||
testtools>=0.9.32
|
||||
mock>=1.0
|
||||
mox3>=0.7.0
|
@ -1,3 +1,4 @@
|
||||
fixtures>=0.3.14
|
||||
testtools>=0.9.34
|
||||
mock>=1.0
|
||||
mox>=0.5.3
|
||||
|
15
test-requirements-py3.txt
Normal file
15
test-requirements-py3.txt
Normal file
@ -0,0 +1,15 @@
|
||||
hacking>=0.8.0,<0.9
|
||||
|
||||
discover
|
||||
python-subunit
|
||||
testrepository>=0.0.17
|
||||
testscenarios>=0.4
|
||||
|
||||
# when we can require tox>= 1.4, this can go into tox.ini:
|
||||
# [testenv:cover]
|
||||
# deps = {[testenv]deps} coverage
|
||||
coverage>=3.6
|
||||
|
||||
# this is required for the docs build jobs
|
||||
sphinx>=1.1.2,<1.2
|
||||
oslosphinx
|
32
tests/unit/test_moxstubout.py
Normal file
32
tests/unit/test_moxstubout.py
Normal file
@ -0,0 +1,32 @@
|
||||
# Copyright 2014 IBM Corp.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo.test import base
|
||||
from oslo.test import moxstubout
|
||||
|
||||
|
||||
class TestMoxStubout(base.BaseTestCase):
|
||||
|
||||
def _stubable(self):
|
||||
pass
|
||||
|
||||
def test_basic_stubout(self):
|
||||
f = self.useFixture(moxstubout.MoxStubout())
|
||||
before = TestMoxStubout._stubable
|
||||
f.mox.StubOutWithMock(TestMoxStubout, '_stubable')
|
||||
after = TestMoxStubout._stubable
|
||||
self.assertNotEqual(before, after)
|
||||
f.cleanUp()
|
||||
after2 = TestMoxStubout._stubable
|
||||
self.assertEqual(before, after2)
|
7
tox.ini
7
tox.ini
@ -8,6 +8,10 @@ deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
commands = python setup.py testr --slowest --testr-args='{posargs}'
|
||||
|
||||
[testenv:py33]
|
||||
deps = -r{toxinidir}/requirements-py3.txt
|
||||
-r{toxinidir}/test-requirements-py3.txt
|
||||
|
||||
[testenv:pep8]
|
||||
commands = flake8
|
||||
|
||||
@ -23,3 +27,6 @@ commands = {posargs}
|
||||
show-source = True
|
||||
exclude = .tox,dist,doc,*.egg,build
|
||||
builtins = _
|
||||
|
||||
[hacking]
|
||||
import_exceptions = six.moves.mox
|
||||
|
Loading…
x
Reference in New Issue
Block a user