
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.
25 lines
592 B
Python
25 lines
592 B
Python
import pytest
|
|
import sqlalchemy as sa
|
|
|
|
from sqlalchemy_utils import is_loaded
|
|
|
|
|
|
@pytest.fixture
|
|
def Article(Base):
|
|
class Article(Base):
|
|
__tablename__ = 'article_translation'
|
|
id = sa.Column(sa.Integer, primary_key=True)
|
|
title = sa.orm.deferred(sa.Column(sa.String(100)))
|
|
return Article
|
|
|
|
|
|
class TestIsLoaded(object):
|
|
|
|
def test_loaded_property(self, Article):
|
|
article = Article(id=1)
|
|
assert is_loaded(article, 'id')
|
|
|
|
def test_unloaded_property(self, Article):
|
|
article = Article(id=4)
|
|
assert not is_loaded(article, 'title')
|