diff --git a/shotgun/test/base.py b/shotgun/test/base.py index 11a68ec..e0565ad 100644 --- a/shotgun/test/base.py +++ b/shotgun/test/base.py @@ -12,8 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -from oslotest import base as oslo_base +from unittest2.case import TestCase -class BaseTestCase(oslo_base.BaseTestCase): +class BaseTestCase(TestCase): """Base unit test case for shotgun tests.""" diff --git a/shotgun/test/test_driver.py b/shotgun/test/test_driver.py index 9f4414e..6115d9d 100644 --- a/shotgun/test/test_driver.py +++ b/shotgun/test/test_driver.py @@ -258,8 +258,6 @@ class TestFile(base.BaseTestCase): class TestCommand(base.BaseTestCase): def setUp(self): - super(TestCommand, self).setUp() - self.conf = mock.Mock() self.conf.target = '/some/dir' @@ -352,8 +350,6 @@ class TestCommand(base.BaseTestCase): class TestDockerCommand(base.BaseTestCase): def setUp(self): - super(TestDockerCommand, self).setUp() - self.conf = mock.Mock() self.conf.target = '/some/dir' diff --git a/shotgun/test/test_manager.py b/shotgun/test/test_manager.py index fc83c97..83dd6ab 100644 --- a/shotgun/test/test_manager.py +++ b/shotgun/test/test_manager.py @@ -151,8 +151,8 @@ class TestManager(base.BaseTestCase): conf.lastdump = tempfile.mkstemp()[1] conf.self_log_object = {"type": "file", "path": "/path"} manager = Manager(conf) - - self.assertRaises(IOError, manager.snapshot) + with self.assertRaises(IOError): + manager.snapshot() calls = [mock.call('/target', onerror=mock.ANY) for _ in range(2)] mrmtree.assert_has_calls(calls) @@ -175,6 +175,6 @@ class TestManager(base.BaseTestCase): conf.lastdump = tempfile.mkstemp()[1] conf.self_log_object = {"type": "file", "path": "/path"} manager = Manager(conf) - - self.assertRaises(IOError, manager.snapshot) + with self.assertRaises(IOError): + manager.snapshot() mrmtree.assert_called_once_with('/target', onerror=mock.ANY) diff --git a/test-requirements.txt b/test-requirements.txt index d8edd15..a472f53 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,8 +1,10 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking<0.11,>=0.10.2 # Apache-2.0 -coverage>=3.6 # Apache-2.0 -os-testr>=0.4.1 # Apache-2.0 -oslotest>=1.10.0 # Apache-2.0 mock>=1.2 # BSD +unittest2 # BSD + +# Packages beyond this line are not in Global Requirements list +# and must be added there. +pytest==2.8.0 +pytest-cov==2.1.0 diff --git a/tox.ini b/tox.ini index 662f3b2..4d3269b 100644 --- a/tox.ini +++ b/tox.ini @@ -10,16 +10,18 @@ setenv = VIRTUAL_ENV={envdir} deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt commands = - ostestr {posargs} + py.test -vv {posargs:shotgun/test} [testenv:pep8] +deps = hacking==0.10 +usedevelop = False commands = flake8 {posargs:shotgun} [testenv:cover] setenv = VIRTUAL_ENV={envdir} commands = - python setup.py test --coverage {posargs} + py.test -vv --cov=shotgun {posargs:shotgun/test} [testenv:venv] commands = {posargs:} @@ -29,6 +31,7 @@ envdir = devenv usedevelop = True [flake8] +ignore = H234,H302,H802 exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,__init__.py,docs show-pep8 = True show-source = True