Skip to content

Commit 2d4f8a0

Browse files
authored
Catch ValueError and raise TableDoesNotExist for describe_table
1 parent 1d789b6 commit 2d4f8a0

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

pynamodb/connection/base.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -582,11 +582,13 @@ def describe_table(self, table_name):
582582
"""
583583
Performs the DescribeTable operation
584584
"""
585-
tbl = self.get_meta_table(table_name, refresh=True)
586-
if tbl:
587-
return tbl.data
588-
else:
589-
raise TableDoesNotExist(table_name)
585+
try:
586+
tbl = self.get_meta_table(table_name, refresh=True)
587+
if tbl:
588+
return tbl.data
589+
except ValueError:
590+
pass
591+
raise TableDoesNotExist(table_name)
590592

591593
def get_conditional_operator(self, operator):
592594
"""

pynamodb/tests/test_base_connection.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,12 @@ def test_describe_table(self):
338338
conn = Connection(self.region)
339339
conn.describe_table(self.test_table_name)
340340

341+
with self.assertRaises(TableDoesNotExist):
342+
with patch(PATCH_METHOD) as req:
343+
req.side_effect = ValueError()
344+
conn = Connection(self.region)
345+
conn.describe_table(self.test_table_name)
346+
341347
def test_list_tables(self):
342348
"""
343349
Connection.list_tables

0 commit comments

Comments
 (0)