SP/web2py/gluon/packages/dal/tests/_helpers.py

26 lines
763 B
Python
Raw Normal View History

2018-10-25 15:33:07 +00:00
from ._compat import unittest
from ._adapt import DEFAULT_URI, drop
from pydal import DAL
class DALtest(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(DALtest, self).__init__(*args, **kwargs)
self._connections = []
def connect(self, *args, **kwargs):
if not args:
kwargs.setdefault('uri', DEFAULT_URI)
kwargs.setdefault('check_reserved', ['all'])
ret = DAL(*args, **kwargs)
self._connections.append(ret)
return ret
def tearDown(self):
for db in self._connections:
db.commit()
tablist = list(db.tables)
for table in reversed(tablist):
drop(db[table])
db.close()
self._connections = []