
Also: Allow override of database name and user in tests (important for me as I would have to mess with my PSQL and MySQL database users otherwise) Use dict.items instead of six.iteritems as it sporadically caused RuntimeError: dictionary changed size during iteration in Python 2.6 tests. Fix typo DNS to DSN Adds Python 3.5 to tox.ini Added an .editorconfig Import babel.dates in sqlalchemy_utils.i18n as an exception would be raised when using the latest versions of babel.
34 lines
785 B
Python
34 lines
785 B
Python
import pytest
|
|
import sqlalchemy as sa
|
|
|
|
from sqlalchemy_utils import table_name
|
|
|
|
|
|
@pytest.fixture
|
|
def Building(Base):
|
|
class Building(Base):
|
|
__tablename__ = 'building'
|
|
id = sa.Column(sa.Integer, primary_key=True)
|
|
name = sa.Column(sa.Unicode(255))
|
|
return Building
|
|
|
|
|
|
@pytest.fixture
|
|
def init_models(Base):
|
|
pass
|
|
|
|
|
|
class TestTableName(object):
|
|
|
|
def test_class(self, Building):
|
|
assert table_name(Building) == 'building'
|
|
del Building.__tablename__
|
|
assert table_name(Building) == 'building'
|
|
|
|
def test_attribute(self, Building):
|
|
assert table_name(Building.id) == 'building'
|
|
assert table_name(Building.name) == 'building'
|
|
|
|
def test_target(self, Building):
|
|
assert table_name(Building()) == 'building'
|