diff options
author | Roger Hu <rhu@hearsaycorp.com> | 2013-06-04 23:22:12 +0000 |
---|---|---|
committer | Roger Hu <rhu@hearsaycorp.com> | 2013-06-04 23:23:24 +0000 |
commit | a86a6ffc7e9b70e85d8192bbf5280366aa8936f6 (patch) | |
tree | 297544e095b3809b07a44ea5efcce5205e983369 | |
parent | 28c0bcdcea9056298229efe06ffd90bc4265bdef (diff) | |
download | happybase-a86a6ffc7e9b70e85d8192bbf5280366aa8936f6.tar.gz |
Try to remove the table if it exists before starting tests.
Aborting the tests half-way causes issues since teardown_module() is not called.
-rw-r--r-- | tests/test_api.py | 9 |
1 files changed, 9 insertions, 0 deletions
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) |