fix flake8 complaints

This commit is contained in:
Friedrich Lindenberg 2017-12-05 17:21:08 +01:00
parent db9729a228
commit 2cf9da068a
3 changed files with 6 additions and 7 deletions

View File

@ -130,7 +130,7 @@ class Database(object):
if error_type is None: if error_type is None:
try: try:
self.commit() self.commit()
except: except Exception:
with safe_reraise(): with safe_reraise():
self.rollback() self.rollback()
else: else:

View File

@ -460,7 +460,7 @@ class Table(object):
offset=_offset) offset=_offset)
if len(order_by): if len(order_by):
query = query.order_by(*order_by) query = query.order_by(*order_by)
conn = self.db.executable conn = self.db.executable
if _streamed: if _streamed:
conn = self.db.engine.connect() conn = self.db.engine.connect()

View File

@ -300,8 +300,8 @@ class TableTestCase(unittest.TestCase):
def test_count(self): def test_count(self):
assert len(self.tbl) == 6, len(self.tbl) assert len(self.tbl) == 6, len(self.tbl)
l = self.tbl.count(place=TEST_CITY_1) length = self.tbl.count(place=TEST_CITY_1)
assert l == 3, l assert length == 3, length
def test_find(self): def test_find(self):
ds = list(self.tbl.find(place=TEST_CITY_1)) ds = list(self.tbl.find(place=TEST_CITY_1))
@ -430,9 +430,8 @@ class TableTestCase(unittest.TestCase):
assert keys[1] == 'place' assert keys[1] == 'place'
def test_empty_query(self): def test_empty_query(self):
m = self.tbl.find(place='not in data') empty = list(self.tbl.find(place='not in data'))
l = list(m) # exhaust iterator assert len(empty) == 0, empty
assert len(l) == 0
class Constructor(dict): class Constructor(dict):