From a86a6ffc7e9b70e85d8192bbf5280366aa8936f6 Mon Sep 17 00:00:00 2001 From: Roger Hu Date: Tue, 4 Jun 2013 23:22:12 +0000 Subject: Try to remove the table if it exists before starting tests. Aborting the tests half-way causes issues since teardown_module() is not called. --- tests/test_api.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_api.py b/tests/test_api.py index 28a4623..3fc41a5 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -43,6 +43,14 @@ connection_kwargs = dict( connection = table = None +def delete_table_if_exists(): + if not KEEP_TABLE: + tables = connection.tables() + if TEST_TABLE_NAME in tables: + print "Table still exists on exit...removing it." + connection.delete_table(TEST_TABLE_NAME, disable=True) + + def setup_module(): global connection, table connection = Connection(**connection_kwargs) @@ -54,6 +62,7 @@ def setup_module(): 'cf2': None, 'cf3': {'max_versions': 1}, } + delete_table_if_exists() connection.create_table(TEST_TABLE_NAME, families=cfs) table = connection.table(TEST_TABLE_NAME) -- cgit v1.2.1