MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_meta_getattr_two

Method test_meta_getattr_two

test/orm/test_utils.py:475–502  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

473 )
474
475 def test_meta_getattr_two(self):
476 class MetaPoint(type):
477 def __getattr__(cls, key):
478 if key == "double_x":
479 return cls._impl_double_x
480 raise AttributeError(key)
481
482 class Point(metaclass=MetaPoint):
483 @hybrid_property
484 def _impl_double_x(self):
485 return self.x * 2
486
487 self._fixture(Point)
488 alias = aliased(Point)
489
490 eq_(str(Point.double_x), "Point._impl_double_x")
491 eq_(str(alias.double_x), "aliased(Point)._impl_double_x")
492 eq_(str(Point.double_x.__clause_element__()), "point.x * :x_1")
493 eq_(str(alias.double_x.__clause_element__()), "point_1.x * :x_1")
494
495 sess = fixture_session()
496
497 self.assert_compile(
498 sess.query(alias).filter(alias.double_x > Point.x),
499 "SELECT point_1.id AS point_1_id, point_1.x AS point_1_x, "
500 "point_1.y AS point_1_y FROM point AS point_1, point "
501 "WHERE point_1.x * :x_1 > point.x",
502 )
503
504 def test_meta_getattr_three(self):
505 class MetaPoint(type):

Callers

nothing calls this directly

Calls 8

_fixtureMethod · 0.95
aliasedFunction · 0.90
eq_Function · 0.90
fixture_sessionFunction · 0.90
assert_compileMethod · 0.80
__clause_element__Method · 0.45
filterMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected