diff options
author | 2020-04-23 10:35:30 -0700 | |
---|---|---|
committer | 2021-05-04 17:48:08 +0200 | |
commit | d3e5cf43918fd6134ce258683a757d4f9778917b (patch) | |
tree | 575488c830794ee345c3c1a4eb2d69047eb4fcbc | |
parent | tests/server.py: Add time.sleep() delay after shutdown (diff) | |
download | g-sorcery-d3e5cf43918fd6134ce258683a757d4f9778917b.tar.gz g-sorcery-d3e5cf43918fd6134ce258683a757d4f9778917b.tar.bz2 g-sorcery-d3e5cf43918fd6134ce258683a757d4f9778917b.zip |
test_DBGenerator.py, test_PackageDB.py: Fix test errors
The http server was not being shutdown when exceptions were raised
This caused other errors in tests run after the failed test.
Signed-off-by: Brian Dolbec <dolsen@gentoo.org>
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r-- | tests/test_DBGenerator.py | 12 | ||||
-rw-r--r-- | tests/test_PackageDB.py | 12 |
2 files changed, 14 insertions, 10 deletions
diff --git a/tests/test_DBGenerator.py b/tests/test_DBGenerator.py index 9a47c86..3c28278 100644 --- a/tests/test_DBGenerator.py +++ b/tests/test_DBGenerator.py @@ -4,9 +4,9 @@ """ test_DBGenerator.py ~~~~~~~~~~~~~~~~~~~ - + DBGenerator test suite - + :copyright: (c) 2013 by Jauhien Piatlicki :license: GPL-2, see LICENSE for more details. """ @@ -81,11 +81,13 @@ class TestDBGenerator(BaseTest): srv = Server(orig_tempdir.name) srv.start() - pkg_db = db_generator(self.tempdir.name, "test_repo", + try: + pkg_db = db_generator(self.tempdir.name, "test_repo", common_config = common_config, config = config) - srv.shutdown() - srv.join() + finally: + srv.shutdown() + srv.join() self.assertEqual(set(pkg_db.list_categories()), set(["app-test1", "app-test2"])) self.assertTrue(pkg_db.in_category("app-test1", "test")) diff --git a/tests/test_PackageDB.py b/tests/test_PackageDB.py index 152c605..8be8f8a 100644 --- a/tests/test_PackageDB.py +++ b/tests/test_PackageDB.py @@ -70,11 +70,13 @@ class TestPackageDB(BaseTest): srv = Server(orig_tempdir.name, port=port) srv.start() - self.assertRaises(IntegrityError, test_db.sync, sync_address) - os.system("cd " + orig_tempdir.name + " && mv good.tar.gz dummy.tar.gz") - test_db.sync(sync_address) - srv.shutdown() - srv.join() + try: + self.assertRaises(IntegrityError, test_db.sync, sync_address) + os.system("cd " + orig_tempdir.name + " && mv good.tar.gz dummy.tar.gz") + test_db.sync(sync_address) + finally: + srv.shutdown() + srv.join() test_db.read() self.assertEqual(orig_db.database, test_db.database) self.assertEqual(orig_db.get_common_data("app-test1"), test_db.get_common_data("app-test1")) |