These were nose methods, and pytest is dropping support for them.
Signed-off-by: Zack Cerza <zack@redhat.com>
from unittest.mock import patch
class TestCheckReImageFailureMarkDown(object):
- def setup(self):
+ def setup_method(self):
self.the_function = supervisor.check_for_reimage_failures_and_mark_down
def create_n_out_of_10_reimage_failed_jobs(self, n):
class TestSuite(Integration):
- def setup(self):
+ def setup_method(self):
self.d = tempfile.mkdtemp()
self.setup_worker()
logging.info("TestSuite: done worker")
class TestSchedule(Integration):
- def setup(self):
+ def setup_method(self):
self.d = tempfile.mkdtemp()
self.setup_worker()
class TestLock(Integration):
- def setup(self):
+ def setup_method(self):
self.options = ['--verbose',
'--machine-type', 'openstack' ]
class TestNuke(Integration):
- def setup(self):
+ def setup_method(self):
self.options = ['--verbose',
'--machine-type', 'openstack']
class TestOpenStack(object):
- def setup(self):
+ def setup_method(self):
self.openstack_config = config['openstack']
def test_config_clone(self):
class TestOpenStackBase(object):
- def setup(self):
+ def setup_method(self):
OpenStack.token = None
OpenStack.token_expires = None
self.environ = {}
if k.startswith('OS_'):
self.environ[k] = os.environ[k]
- def teardown(self):
+ def teardown_method(self):
OpenStack.token = None
OpenStack.token_expires = None
for k in os.environ.keys():
else:
self.can_create_floating_ips = False
- def setup(self):
- super(TestTeuthologyOpenStack, self).setup()
+ def setup_method(self):
+ super(TestTeuthologyOpenStack, self).setup_method()
self.key_filename = tempfile.mktemp()
self.key_name = 'teuthology-test'
self.name = 'teuthology-test'
'--name', self.name,
'--verbose']
- def teardown(self):
- super(TestTeuthologyOpenStack, self).teardown()
+ def teardown_method(self):
+ super(TestTeuthologyOpenStack, self).teardown_method()
self.clobber()
os.unlink(self.key_filename)
class TestIntegration():
- def setup(self):
+ def setup_method(self):
try:
host = os.environ['ORCHESTRA_TEST_HOST']
except KeyError:
class TestWriteFile(object):
""" Tests for cluster.write_file """
- def setup(self):
+ def setup_method(self):
self.r1 = remote.Remote('r1', ssh=Mock())
self.c = cluster.Cluster(
remotes=[
class TestConnection(object):
- def setup(self):
+ def setup_method(self):
self.start_patchers()
- def teardown(self):
+ def teardown_method(self):
self.stop_patchers()
def start_patchers(self):
ipmi_cmd_templ = 'ipmitool -H {h}.{d} -I lanplus -U {u} -P {p} {c}'
conserver_cmd_templ = 'console -M {m} -p {p} {mode} {h}'
- def setup(self):
+ def setup_method(self):
self.hostname = 'host'
teuth_config.ipmi_domain = 'ipmi_domain'
teuth_config.ipmi_user = 'ipmi_user'
class TestRemote(object):
- def setup(self):
+ def setup_method(self):
self.start_patchers()
- def teardown(self):
+ def teardown_method(self):
self.stop_patchers()
def start_patchers(self):
class TestRun(object):
- def setup(self):
+ def setup_method(self):
self.start_patchers()
- def teardown(self):
+ def teardown_method(self):
self.stop_patchers()
def start_patchers(self):
class TestBase(object):
- def setup(self):
+ def setup_method(self):
config.load()
config.libcloud = dummy_config
cloud.supported_drivers['dummy'] = dummy_drivers
- def teardown(self):
+ def teardown_method(self):
del cloud.supported_drivers['dummy']
class TestInit(object):
- def setup(self):
+ def setup_method(self):
config.load()
config.libcloud = dummy_config
cloud.supported_drivers['dummy'] = dummy_drivers
- def teardown(self):
+ def teardown_method(self):
del cloud.supported_drivers['dummy']
def test_get_types(self):
class TestAuthToken(object):
klass = util.AuthToken
- def setup(self):
+ def setup_method(self):
default_expires = get_datetime_string(0)
self.test_data = dict(
value='token_value',
for name, patcher in self.patchers.items():
self.mocks[name] = patcher.start()
- def teardown(self):
+ def teardown_method(self):
for patcher in self.patchers.values():
patcher.stop()
class TestOpenStackBase(object):
- def setup(self):
+ def setup_method(self):
config.load(dict(libcloud=deepcopy(test_config)))
self.start_patchers()
self.mocks[name] = patcher.start()
self.mocks['m_get_endpoint'].return_value = 'endpoint'
- def teardown(self):
+ def teardown_method(self):
for patcher in self.patchers.values():
patcher.stop()
class TestDownburst(object):
- def setup(self):
+ def setup_method(self):
self.ctx = Mock()
self.ctx.os_type = 'rhel'
self.ctx.os_version = '7.0'
class TestFOG(object):
klass = fog.FOG
- def setup(self):
+ def setup_method(self):
config.load()
config.update(deepcopy(test_config))
self.start_patchers()
for name, patcher in self.patchers.items():
self.mocks[name] = patcher.start()
- def teardown(self):
+ def teardown_method(self):
for patcher in self.patchers.values():
patcher.stop()
class TestInitProvision(object):
- def setup(self):
+ def setup_method(self):
config.load(deepcopy(test_config))
def test_get_reimage_types(self):
class TestPelagos(object):
- def setup(self):
+ def setup_method(self):
config.load(deepcopy(test_config))
- def teardown(self):
+ def teardown_method(self):
pass
def test_get_types(self):
'builtins.open',
]
- def setup(self):
+ def setup_method(self):
self.mocks = dict()
self.patchers = dict()
for ppoint in self.__class__.patchpoints:
for patcher in self.patchers.values():
patcher.stop()
- def teardown(self):
+ def teardown_method(self):
self.patchers.clear()
self.mocks.clear()
'builtins.open',
]
- def setup(self):
+ def setup_method(self):
self.mocks = dict()
self.patchers = dict()
for ppoint in self.__class__.patchpoints:
for patcher in self.patchers.values():
patcher.stop()
- def teardown(self):
+ def teardown_method(self):
self.patchers.clear()
self.mocks.clear()
'builtins.open',
]
- def setUp(self):
+ def setup_method(self):
log.debug("setUp")
self.mocks = dict()
self.patchers = dict()
for patcher in self.patchers.values():
patcher.stop()
- def tearDown(self):
- log.debug("tearDown")
+ def teardown_method(self):
self.patchers.clear()
self.mocks.clear()
class TestRun(object):
klass = run.Run
- def setup(self):
+ def setup_method(self):
self.args_dict = dict(
suite='suite',
suite_branch='suite_branch',
class TestScheduleSuite(object):
klass = run.Run
- def setup(self):
+ def setup_method(self):
self.args_dict = dict(
suite='suite',
suite_relpath='',
class TestUtil(object):
- def setup(self):
+ def setup_method(self):
config.use_shaman = False
@patch('teuthology.suite.util.smtplib.SMTP')
Tests the functionality that checks to see if a
scheduled job will have missing packages in gitbuilder.
"""
- def setup(self):
+ def setup_method(self):
package_versions = {
'sha1': {
'ubuntu': {
class TestDistroDefaults(object):
- def setup(self):
+ def setup_method(self):
config.use_shaman = False
def test_distro_defaults_saya(self):
def communicate(self, input=None):
return [TestFetchCoreDumps.MockDecode(self.ret)]
- def setup(self):
+ def setup_method(self):
self.the_function = fetch_binaries_for_coredumps
with gzip.open('file.gz', 'wb') as f:
f.write(b'Hello world!')
class TestSuiteOnline(object):
- def setup(self):
+ def setup_method(self):
if 'TEST_ONLINE' not in os.environ:
skip("To run these sets, set the environment variable TEST_ONLINE")
klass = Task
task_name = 'task'
- def setup(self):
+ def setup_method(self):
self.ctx = FakeNamespace()
self.ctx.config = dict()
self.task_config = dict()
klass = Ansible
task_name = 'ansible'
- def setup(self):
- pass
-
- def setup_method(self, method):
+ def setup_method(self):
self.ctx = FakeNamespace()
self.ctx.cluster = Cluster()
self.ctx.cluster.add(Remote('user@remote1'), ['role1'])
klass = CephLab
task_name = 'ansible.cephlab'
- def setup(self):
- super(TestCephLabTask, self).setup()
+ def setup_method(self):
+ super(TestCephLabTask, self).setup_method()
self.task_config = dict()
def start_patchers(self):
klass = CephAnsible
task_name = 'ceph_ansible'
- def setup(self):
+ def setup_method(self):
self.ctx = FakeNamespace()
self.ctx.cluster = Cluster()
self.ctx.cluster.add(Remote('user@remote1'), ['mon.0'])
klass = ConsoleLog
task_name = 'console_log'
- def setup(self):
+ def setup_method(self):
teuth_config.ipmi_domain = 'ipmi.domain'
teuth_config.ipmi_user = 'ipmi_user'
teuth_config.ipmi_password = 'ipmi_pass'
self.mocks[name] = patcher.start()
self.mocks['is_vm'].return_value = False
- def teardown(self):
+ def teardown_method(self):
for patcher in self.patchers.values():
patcher.stop()
class TestInternal(object):
- def setup(self):
+ def setup_method(self):
self.ctx = FakeNamespace()
self.ctx.config = dict()
class TestKernelNormalizeAndApplyOverrides(object):
- def setup(self):
+ def setup_method(self):
self.ctx = FakeNamespace()
self.ctx.cluster = Cluster()
self.ctx.cluster.add(Remote('remote1'), ['mon.a', 'client.0'])
class TestPCPDataSource(object):
klass = PCPDataSource
- def setup(self):
+ def setup_method(self):
config.pcp_host = pcp_host
def test_init(self):
klass = PCP
task_name = 'pcp'
- def setup(self):
+ def setup_method(self):
self.ctx = FakeNamespace()
self.ctx.cluster = Cluster()
self.ctx.cluster.add(Remote('user@remote1'), ['role1'])
class TestSELinux(object):
- def setup(self):
+ def setup_method(self):
self.ctx = FakeNamespace()
self.ctx.config = dict()
class TestYamlConfig(object):
- def setup(self):
+ def setup_method(self):
self.test_class = config.YamlConfig
def test_set_multiple(self):
class TestTeuthologyConfig(TestYamlConfig):
- def setup(self):
+ def setup_method(self):
self.test_class = config.TeuthologyConfig
def test_get_ceph_git_base_default(self):
class TestJobConfig(TestYamlConfig):
- def setup(self):
+ def setup_method(self):
self.test_class = config.JobConfig
class TestFakeNamespace(TestYamlConfig):
- def setup(self):
+ def setup_method(self):
self.test_class = config.FakeNamespace
def test_docopt_dict(self):
class TestSafeWhile(object):
- def setup(self):
+ def setup_method(self):
contextutil.log.setLevel(ERROR)
self.fake_sleep = lambda s: True
self.s_while = contextutil.safe_while
class TestDescribeTests(object):
- def setup(self):
+ def setup_method(self):
self.mocks = dict()
self.patchers = dict()
exists, listdir, isfile, isdir, open = make_fake_fstools(realistic_fs)
for patcher in self.patchers.values():
patcher.stop()
- def teardown(self):
+ def teardown_method(self):
self.stop_patchers()
@staticmethod
from textwrap import dedent
class TestSleepBeforeTeardownEmail(object):
- def setup(self):
+ def setup_method(self):
config.results_ui_server = "http://example.com/"
config.archive_server = "http://qa-proxy.ceph.com/teuthology/"
class TestExiter(object):
klass = exit.Exiter
- def setup(self):
+ def setup_method(self):
self.pid = os.getpid()
# Below, we patch os.kill() in such a way that the first time it is
self.m_kill.side_effect = m_kill_unwrap
- def teardown(self):
+ def teardown_method(self):
self.patcher_kill.stop()
del self.m_kill
class TestGetDistro(object):
- def setup(self):
+ def setup_method(self):
self.fake_ctx = Mock()
self.fake_ctx.config = {}
# os_type in ctx will always default to None
class TestGetDistroVersion(object):
- def setup(self):
+ def setup_method(self):
self.fake_ctx = Mock()
self.fake_ctx.config = {}
self.fake_ctx_noarg = Mock()
assert actual_split == expected_split
class TestHostnames(object):
- def setup(self):
+ def setup_method(self):
config._conf = dict()
- def teardown(self):
+ def teardown_method(self):
config.load()
def test_canonicalize_hostname(self):
class TestBuilderProject(object):
klass = None
- def setup(self):
+ def setup_method(self):
if self.klass is None:
pytest.skip()
class TestShamanProject(TestBuilderProject):
klass = packaging.ShamanProject
- def setup(self):
+ def setup_method(self):
self.p_config = patch('teuthology.packaging.config')
self.m_config = self.p_config.start()
self.m_config.use_shaman = True
self.p_get = patch('requests.get')
self.m_get = self.p_get.start()
- def teardown(self):
+ def teardown_method(self):
self.p_config.stop()
self.p_get_config_value.stop()
self.p_get.stop()
class TestSerializer(object):
- def setup(self):
+ def setup_method(self):
self.archive = fake_archive.FakeArchive()
self.archive.setup()
self.archive_base = self.archive.archive_base
self.reporter = report.ResultsReporter(archive_base=self.archive_base)
- def teardown(self):
+ def teardown_method(self):
self.archive.teardown()
def test_all_runs_one_run(self):
""").strip(),
}
- def setup(self):
+ def setup_method(self):
config.results_ui_server = "http://example.com/"
config.archive_server = "http://qa-proxy.ceph.com/teuthology/"
class TestVpsOsVersionParamCheck(object):
- def setup(self):
+ def setup_method(self):
self.fake_ctx = Mock()
self.fake_ctx.machine_type = 'vps'
self.fake_ctx.num_to_lock = 1
class TestWorker(object):
- def setup(self):
+ def setup_method(self):
self.ctx = Mock()
self.ctx.verbose = True
self.ctx.archive_dir = '/archive/dir'