add __contains__
This commit is contained in:
parent
1bdd35ee84
commit
17bad827ae
@ -141,6 +141,9 @@ class Database(object):
|
|||||||
set(self.metadata.tables.keys()) | set(self._tables.keys())
|
set(self.metadata.tables.keys()) | set(self._tables.keys())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def __contains__(self, member):
|
||||||
|
return member in self.tables
|
||||||
|
|
||||||
def create_table(self, table_name, primary_id='id', primary_type='Integer'):
|
def create_table(self, table_name, primary_id='id', primary_type='Integer'):
|
||||||
"""
|
"""
|
||||||
Creates a new table. The new table will automatically have an `id` column
|
Creates a new table. The new table will automatically have an `id` column
|
||||||
|
|||||||
@ -38,6 +38,9 @@ class DatabaseTestCase(unittest.TestCase):
|
|||||||
def test_tables(self):
|
def test_tables(self):
|
||||||
assert self.db.tables == ['weather'], self.db.tables
|
assert self.db.tables == ['weather'], self.db.tables
|
||||||
|
|
||||||
|
def test_contains(self):
|
||||||
|
assert 'weather' in self.db, self.db.tables
|
||||||
|
|
||||||
def test_create_table(self):
|
def test_create_table(self):
|
||||||
table = self.db['foo']
|
table = self.db['foo']
|
||||||
assert table.table.exists()
|
assert table.table.exists()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user