Skip to content

Commit

Permalink
Remove nested ‘with’ statements for better legibility
Browse files Browse the repository at this point in the history
  • Loading branch information
samdoran committed Apr 4, 2024
1 parent 89e9340 commit 90ac78e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions koku/masu/test/api/test_db_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ def test_ssl(self, ca):

def test_bad_sql(self):
"""Test that bad sql will throw an exception."""
with DBPerformanceStats("KOKU", CONFIGURATOR) as dbp:
with self.assertRaises(UndefinedTable):
dbp._execute("""select * from no_table_here;""")
with (
DBPerformanceStats("KOKU", CONFIGURATOR) as dbp,
self.assertRaises(UndefinedTable),
):
dbp._execute("""select * from no_table_here;""")

def test_del_closes_connection(self):
"""Test that instance delete closes the connection"""
Expand Down Expand Up @@ -190,9 +192,11 @@ def test_explain(self):
"delete from eek",
]
for bad_sql in bad_statements:
with self.assertRaises(ProgrammingError, msg=f"Failing statement is {bad_sql}"):
with DBPerformanceStats("KOKU", CONFIGURATOR) as dbp:
res = dbp.explain_sql(bad_sql)
with (
self.assertRaises(ProgrammingError, msg=f"Failing statement is {bad_sql}"),
DBPerformanceStats("KOKU", CONFIGURATOR) as dbp,
):
res = dbp.explain_sql(bad_sql)

expected = [
{
Expand Down

0 comments on commit 90ac78e

Please sign in to comment.