diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-12-12 12:49:57 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-12-12 12:53:34 -0500 |
| commit | 69154698d20d1c15cee83990ec719d1deaf193ae (patch) | |
| tree | b1e6dd953a1e4a126c85c4ec5e3efdb09f82238c /test/ext/declarative/test_basic.py | |
| parent | a6eaf1cceb00f81053a3139c38e9650ecc297cc0 (diff) | |
| download | sqlalchemy-69154698d20d1c15cee83990ec719d1deaf193ae.tar.gz | |
- Error message when a string arg sent to :func:`.relationship` which
doesn't resolve to a class or mapper has been corrected to work
the same way as when a non-string arg is received, which indicates
the name of the relationship which had the configurational error.
[ticket:2888]
Conflicts:
lib/sqlalchemy/orm/relationships.py
Diffstat (limited to 'test/ext/declarative/test_basic.py')
| -rw-r--r-- | test/ext/declarative/test_basic.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ext/declarative/test_basic.py b/test/ext/declarative/test_basic.py index 4b5736c9f..1596b78d3 100644 --- a/test/ext/declarative/test_basic.py +++ b/test/ext/declarative/test_basic.py @@ -123,6 +123,38 @@ class DeclarativeTest(DeclarativeTestBase): assert class_mapper(Bar).get_property('some_data').columns[0] \ is t.c.data + def test_relationship_level_msg_for_invalid_callable(self): + class A(Base): + __tablename__ = 'a' + id = Column(Integer, primary_key=True) + class B(Base): + __tablename__ = 'b' + id = Column(Integer, primary_key=True) + a_id = Column(Integer, ForeignKey('a.id')) + a = relationship('a') + assert_raises_message( + sa.exc.ArgumentError, + "relationship 'a' expects a class or a mapper " + "argument .received: .*Table", + configure_mappers + ) + + def test_relationship_level_msg_for_invalid_object(self): + class A(Base): + __tablename__ = 'a' + id = Column(Integer, primary_key=True) + class B(Base): + __tablename__ = 'b' + id = Column(Integer, primary_key=True) + a_id = Column(Integer, ForeignKey('a.id')) + a = relationship(A.__table__) + assert_raises_message( + sa.exc.ArgumentError, + "relationship 'a' expects a class or a mapper " + "argument .received: .*Table", + configure_mappers + ) + def test_difficult_class(self): """test no getattr() errors with a customized class""" |
