Skip to content

Commit 06e9a98

Browse files
committed
Implement teardown functionality for yaml tests
1 parent a53efe1 commit 06e9a98

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test_elasticsearch/test_server/test_common.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def setUp(self):
5050
self._state = {}
5151

5252
def tearDown(self):
53+
if hasattr(self, '_teardown_code'):
54+
self.run_code(self._teardown_code)
5355
super(YamlTestCase, self).tearDown()
5456
for repo, definition in self.client.snapshot.get_repository(repository='_all').items():
5557
self.client.snapshot.delete_repository(repository=repo)
@@ -255,8 +257,8 @@ def m(self):
255257
i = 0
256258
for test in tests:
257259
for test_name, definition in test.items():
258-
if test_name == 'setup':
259-
attrs['_setup_code'] = definition
260+
if test_name in ('setup', 'teardown'):
261+
attrs['_%s_code' % test_name] = definition
260262
continue
261263

262264
attrs['test_from_yaml_%d' % i] = make_test(test_name, definition, i)

0 commit comments

Comments
 (0)