MCPcopy Index your code
hub / github.com/sqlalchemy/sqlalchemy / _fixture

Method _fixture

test/orm/test_attributes.py:1487–1528  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1485
1486class PendingBackrefTest(fixtures.ORMTest):
1487 def _fixture(self):
1488 class Post:
1489 def __init__(self, name):
1490 self.name = name
1491
1492 __hash__ = None
1493
1494 def __eq__(self, other):
1495 return other is not None and other.name == self.name
1496
1497 class Blog:
1498 def __init__(self, name):
1499 self.name = name
1500
1501 __hash__ = None
1502
1503 def __eq__(self, other):
1504 return other is not None and other.name == self.name
1505
1506 lazy_posts = Mock()
1507
1508 instrumentation.register_class(Post)
1509 instrumentation.register_class(Blog)
1510 _register_attribute(
1511 Post,
1512 "blog",
1513 uselist=False,
1514 backref="posts",
1515 trackparent=True,
1516 useobject=True,
1517 )
1518 _register_attribute(
1519 Blog,
1520 "posts",
1521 uselist=True,
1522 backref="blog",
1523 callable_=lazy_posts,
1524 trackparent=True,
1525 useobject=True,
1526 )
1527
1528 return Post, Blog, lazy_posts
1529
1530 def test_lazy_add(self):
1531 Post, Blog, lazy_posts = self._fixture()

Calls 1

_register_attributeFunction · 0.70

Tested by

no test coverage detected