(self)
| 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): |
nothing calls this directly
no test coverage detected