SP/web2py/gluon/packages/dal/tests/_helpers.py
Saturneic 064f602b1a Add.
2018-10-25 23:33:13 +08:00

26 lines
763 B
Python

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 = []