| 258 | assert Point.max_x is alias.max_x |
| 259 | |
| 260 | def test_descriptors(self): |
| 261 | class descriptor: |
| 262 | def __init__(self, fn): |
| 263 | self.fn = fn |
| 264 | |
| 265 | def __get__(self, obj, owner): |
| 266 | if obj is not None: |
| 267 | return self.fn(obj, obj) |
| 268 | else: |
| 269 | return self |
| 270 | |
| 271 | def method(self): |
| 272 | return "method" |
| 273 | |
| 274 | class Point: |
| 275 | center = (0, 0) |
| 276 | |
| 277 | @descriptor |
| 278 | def thing(self, arg): |
| 279 | return arg.center |
| 280 | |
| 281 | self._fixture(Point) |
| 282 | alias = aliased(Point) |
| 283 | |
| 284 | assert Point.thing != (0, 0) |
| 285 | assert Point().thing == (0, 0) |
| 286 | assert Point.thing.method() == "method" |
| 287 | |
| 288 | assert alias.thing != (0, 0) |
| 289 | assert alias.thing.method() == "method" |
| 290 | |
| 291 | def _assert_has_table(self, expr, table): |
| 292 | from sqlalchemy import Column # override testlib's override |