tests: use cloudinit.tests.TestCase everywhere
It seems sane to have consistent use of a 'TestCase' class wherever possible. I stumbled on need for this in porting some code (the reporter) back to cloud-init 0.7. Change-Id: Ia10546484dfe73154a68e817129ac2f950d5fe85
This commit is contained in:
parent
a433358bbc
commit
c8fd01e292
@ -13,13 +13,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import unittest
|
||||
|
||||
from cloudinit.osys import base
|
||||
from cloudinit.tests import TestCase
|
||||
from cloudinit.tests.util import mock
|
||||
|
||||
|
||||
class TestOSUtils(unittest.TestCase):
|
||||
class TestOSUtils(TestCase):
|
||||
|
||||
@mock.patch('importlib.import_module')
|
||||
@mock.patch('platform.linux_distribution')
|
||||
|
@ -4,15 +4,16 @@
|
||||
# vi: ts=4 expandtab
|
||||
|
||||
import importlib
|
||||
import unittest
|
||||
|
||||
from cloudinit import exceptions
|
||||
from cloudinit.tests import TestCase
|
||||
from cloudinit.tests.util import mock
|
||||
|
||||
|
||||
class TestWindowsGeneral(unittest.TestCase):
|
||||
class TestWindowsGeneral(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestWindowsGeneral, self).setUp()
|
||||
self._ctypes_mock = mock.Mock()
|
||||
self._util_mock = mock.MagicMock()
|
||||
self._module_patcher = mock.patch.dict(
|
||||
@ -27,6 +28,7 @@ class TestWindowsGeneral(unittest.TestCase):
|
||||
self._general = self._general_module.General()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestWindowsGeneral, self).tearDown()
|
||||
self._module_patcher.stop()
|
||||
|
||||
def _test_check_os_version(self, ret_value, error_value=None):
|
||||
|
@ -3,8 +3,6 @@
|
||||
#
|
||||
# vi: ts=4 expandtab
|
||||
|
||||
import unittest
|
||||
|
||||
from cloudinit import reporting
|
||||
from cloudinit.tests import TestCase
|
||||
from cloudinit.tests.util import mock
|
||||
@ -15,7 +13,7 @@ def _fake_registry():
|
||||
'b': mock.MagicMock()})
|
||||
|
||||
|
||||
class TestReportStartEvent(unittest.TestCase):
|
||||
class TestReportStartEvent(TestCase):
|
||||
|
||||
@mock.patch('cloudinit.reporting.instantiated_handler_registry',
|
||||
new_callable=_fake_registry)
|
||||
@ -32,7 +30,7 @@ class TestReportStartEvent(unittest.TestCase):
|
||||
self.assertEqual(expected_string_representation, event.as_string())
|
||||
|
||||
|
||||
class TestReportFinishEvent(unittest.TestCase):
|
||||
class TestReportFinishEvent(TestCase):
|
||||
|
||||
def _report_finish_event(self, successful=None):
|
||||
event_name, event_description = 'my_test_event', 'my description'
|
||||
@ -83,7 +81,7 @@ class TestReportFinishEvent(unittest.TestCase):
|
||||
expected_string_representation)
|
||||
|
||||
|
||||
class TestReportingEvent(unittest.TestCase):
|
||||
class TestReportingEvent(TestCase):
|
||||
|
||||
def test_as_string(self):
|
||||
event_type, name, description = 'test_type', 'test_name', 'test_desc'
|
||||
|
@ -4,12 +4,12 @@
|
||||
# vi: ts=4 expandtab
|
||||
|
||||
from cloudinit import safeyaml as yaml
|
||||
from cloudinit import tests
|
||||
from cloudinit.tests import TestCase
|
||||
|
||||
import tempfile
|
||||
|
||||
|
||||
class TestSafeYaml(tests.TestCase):
|
||||
class TestSafeYaml(TestCase):
|
||||
def test_simple(self):
|
||||
blob = '\nk1: one\nk2: two'
|
||||
expected = {'k1': "one", 'k2': "two"}
|
||||
|
@ -9,10 +9,10 @@ import os
|
||||
import textwrap
|
||||
|
||||
from cloudinit import templater
|
||||
from cloudinit import tests
|
||||
from cloudinit.tests import TestCase
|
||||
|
||||
|
||||
class TestTemplates(tests.TestCase):
|
||||
class TestTemplates(TestCase):
|
||||
jinja_tmpl = '\n'.join((
|
||||
"## template:jinja",
|
||||
"{{a}},{{b}}",
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
import httpretty
|
||||
|
||||
from cloudinit import tests
|
||||
from cloudinit.tests import TestCase
|
||||
from cloudinit.tests.util import mock
|
||||
from cloudinit import url_helper
|
||||
|
||||
@ -24,7 +24,7 @@ class TimeJumpSideEffect(object):
|
||||
return next(self.time)
|
||||
|
||||
|
||||
class UrlHelperWaitForUrlsTest(tests.TestCase):
|
||||
class UrlHelperWaitForUrlsTest(TestCase):
|
||||
|
||||
@httpretty.activate
|
||||
def test_url_wait_for(self):
|
||||
@ -68,7 +68,7 @@ class UrlHelperWaitForUrlsTest(tests.TestCase):
|
||||
self.assertIsNone(url_helper.wait_any_url(urls, max_wait=1))
|
||||
|
||||
|
||||
class UrlHelperFetchTest(tests.TestCase):
|
||||
class UrlHelperFetchTest(TestCase):
|
||||
|
||||
@httpretty.activate
|
||||
def test_url_fetch(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user