예제 #1
0
 def test_cursor_shutdown_in_initialize(self):
     db = self._fixture(True, True)
     assert_warns_message(exc.SAWarning, "Exception attempting to detect",
                          db.connect)
     eq_(
         db.pool.logger.error.mock_calls,
         [call("Error closing cursor", exc_info=True)],
     )
예제 #2
0
 def _assert_non_simple_warning(self, fn):
     assert_warns_message(
         exc.SAWarning,
         "Non-simple column elements in "
         "primary join condition for property "
         r"None - consider using remote\(\) "
         "annotations to mark the remote side.",
         fn,
     )
예제 #3
0
    def test_del_warning(self):
        class A:
            def __del__(self):
                pass

        assert_warns_message(
            sa.exc.SAWarning,
            r"__del__\(\) method on class "
            r"<class '.*\.A'> will cause "
            r"unreachable cycles and memory leaks, as SQLAlchemy "
            r"instrumentation often creates reference cycles.  "
            r"Please remove this method.",
            self.mapper_registry.map_imperatively,
            A,
            self.fixture(),
        )
예제 #4
0
    def test_config_errors(self):
        Session = scoped_session(sa.orm.sessionmaker())

        s = Session()  # noqa
        assert_raises_message(
            sa.exc.InvalidRequestError,
            "Scoped session is already present",
            Session,
            bind=testing.db,
        )

        assert_warns_message(
            sa.exc.SAWarning,
            "At least one scoped session is already present. ",
            Session.configure,
            bind=testing.db,
        )
예제 #5
0
 def test_no_m2o_w_uselist(self):
     users, Address, addresses, User = (
         self.tables.users,
         self.classes.Address,
         self.tables.addresses,
         self.classes.User,
     )
     self.mapper_registry.map_imperatively(
         Address,
         addresses,
         properties={
             "user": relationship(User, uselist=True, lazy="dynamic")
         },
     )
     self.mapper_registry.map_imperatively(User, users)
     assert_warns_message(
         exc.SAWarning,
         "On relationship Address.user, 'dynamic' loaders cannot be "
         "used with many-to-one/one-to-one relationships and/or "
         "uselist=False.",
         configure_mappers,
     )