(self)
| 3826 | |
| 3827 | class EnsureCacheTest(UOWTest): |
| 3828 | def test_ensure_cache(self): |
| 3829 | users, User = self.tables.users, self.classes.User |
| 3830 | |
| 3831 | self.mapper_registry.map_imperatively(User, users) |
| 3832 | |
| 3833 | cache = {} |
| 3834 | eq_(len(inspect(User)._compiled_cache), 0) |
| 3835 | |
| 3836 | with testing.db.connect().execution_options( |
| 3837 | compiled_cache=cache |
| 3838 | ) as conn: |
| 3839 | s = Session(conn) |
| 3840 | u1 = User(name="adf") |
| 3841 | s.add(u1) |
| 3842 | s.flush() |
| 3843 | |
| 3844 | is_(conn._execution_options["compiled_cache"], cache) |
| 3845 | eq_(len(inspect(User)._compiled_cache), 1) |
| 3846 | |
| 3847 | u1.name = "newname" |
| 3848 | s.flush() |
| 3849 | |
| 3850 | is_(conn._execution_options["compiled_cache"], cache) |
| 3851 | eq_(len(inspect(User)._compiled_cache), 2) |
| 3852 | |
| 3853 | s.delete(u1) |
| 3854 | s.flush() |
| 3855 | |
| 3856 | is_(conn._execution_options["compiled_cache"], cache) |
| 3857 | eq_(len(inspect(User)._compiled_cache), 3) |
| 3858 | |
| 3859 | |
| 3860 | class ORMOnlyPrimaryKeyTest(fixtures.TestBase): |
nothing calls this directly
no test coverage detected