Files
@ 9343ba3fb2c8
Branch filter:
Location: rattail-project/rattail/tests/__init__.py - annotation
9343ba3fb2c8
1.4 KiB
text/x-python
Tweak `locking_copy_test()` to assume destination is always a folder.
Also add constant for "file exists" error.
Also add constant for "file exists" error.
92c03f5d8db0 92c03f5d8db0 92c03f5d8db0 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 177478f7d054 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import warnings
from unittest import TestCase
from sqlalchemy import create_engine
from sqlalchemy.exc import SAWarning
from rattail.db import model
from rattail.db import Session
warnings.filterwarnings(
'ignore',
r"^Dialect sqlite\+pysqlite does \*not\* support Decimal objects natively\, "
"and SQLAlchemy must convert from floating point - rounding errors and other "
"issues may occur\. Please consider storing Decimal numbers as strings or "
"integers on this platform for lossless storage\.$",
SAWarning, r'^sqlalchemy\..*$')
class DataTestCase(TestCase):
engine_url = os.environ.get('RATTAIL_TEST_ENGINE_URL', 'sqlite://')
def setUp(self):
self.engine = create_engine(self.engine_url)
model.Base.metadata.create_all(bind=self.engine)
Session.configure(bind=self.engine)
self.session = Session()
def tearDown(self):
self.session.close()
Session.configure(bind=None)
model.Base.metadata.drop_all(bind=self.engine)
# # TODO: This doesn't seem to be necessary, hopefully that's good?
# for table in list(model.Base.metadata.sorted_tables):
# if table.name.startswith('batch.'):
# model.Base.metadata.remove(table)
# TODO: Unfortunately this *does* seem to be necessary...
model.Batch._rowclasses.clear()
|