当前位置: 首页>>代码示例>>Python>>正文


Python testing.expect_deprecated函数代码示例

本文整理汇总了Python中sqlalchemy.testing.expect_deprecated函数的典型用法代码示例。如果您正苦于以下问题:Python expect_deprecated函数的具体用法?Python expect_deprecated怎么用?Python expect_deprecated使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了expect_deprecated函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_deprecated_append_ddl_listener_table

    def test_deprecated_append_ddl_listener_table(self):
        metadata, users, engine = self.metadata, self.users, self.engine
        canary = []
        with testing.expect_deprecated(".* is deprecated .*"):
            users.append_ddl_listener(
                "before-create", lambda e, t, b: canary.append("mxyzptlk")
            )
        with testing.expect_deprecated(".* is deprecated .*"):
            users.append_ddl_listener(
                "after-create", lambda e, t, b: canary.append("klptzyxm")
            )
        with testing.expect_deprecated(".* is deprecated .*"):
            users.append_ddl_listener(
                "before-drop", lambda e, t, b: canary.append("xyzzy")
            )
        with testing.expect_deprecated(".* is deprecated .*"):
            users.append_ddl_listener(
                "after-drop", lambda e, t, b: canary.append("fnord")
            )

        metadata.create_all()
        assert "mxyzptlk" in canary
        assert "klptzyxm" in canary
        assert "xyzzy" not in canary
        assert "fnord" not in canary
        del engine.mock[:]
        canary[:] = []
        metadata.drop_all()
        assert "mxyzptlk" not in canary
        assert "klptzyxm" not in canary
        assert "xyzzy" in canary
        assert "fnord" in canary
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:32,代码来源:test_deprecations.py

示例2: test_table_useexisting

    def test_table_useexisting(self):
        meta = self.metadata

        Table("t", meta, Column("x", Integer))
        meta.create_all()

        with testing.expect_deprecated(
            "The Table.useexisting parameter is deprecated and "
            "will be removed in a future release."
        ):
            Table("t", meta, useexisting=True, autoload_with=testing.db)

        with testing.expect_deprecated(
            "The Table.useexisting parameter is deprecated and "
            "will be removed in a future release."
        ):
            assert_raises_message(
                exc.ArgumentError,
                "useexisting is synonymous with extend_existing.",
                Table,
                "t",
                meta,
                useexisting=True,
                extend_existing=True,
                autoload_with=testing.db,
            )
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:26,代码来源:test_deprecations.py

示例3: test_scalar_select

    def test_scalar_select(self):

        with testing.expect_deprecated(
            "coercing SELECT object to scalar "
            "subquery in a column-expression context is deprecated"
        ):
            self.assert_compile(
                func.coalesce(select([table1.c.myid])),
                "coalesce((SELECT mytable.myid FROM mytable))",
            )

        with testing.expect_deprecated(
            "coercing SELECT object to scalar "
            "subquery in a column-expression context is deprecated"
        ):
            s = select([table1.c.myid]).alias()
            self.assert_compile(
                select([table1.c.myid]).where(table1.c.myid == s),
                "SELECT mytable.myid FROM mytable WHERE "
                "mytable.myid = (SELECT mytable.myid FROM "
                "mytable)",
            )

        with testing.expect_deprecated(
            "coercing SELECT object to scalar "
            "subquery in a column-expression context is deprecated"
        ):
            self.assert_compile(
                select([table1.c.myid]).where(s > table1.c.myid),
                "SELECT mytable.myid FROM mytable WHERE "
                "mytable.myid < (SELECT mytable.myid FROM "
                "mytable)",
            )

        with testing.expect_deprecated(
            "coercing SELECT object to scalar "
            "subquery in a column-expression context is deprecated"
        ):
            s = select([table1.c.myid]).alias()
            self.assert_compile(
                select([table1.c.myid]).where(table1.c.myid == s),
                "SELECT mytable.myid FROM mytable WHERE "
                "mytable.myid = (SELECT mytable.myid FROM "
                "mytable)",
            )

        with testing.expect_deprecated(
            "coercing SELECT object to scalar "
            "subquery in a column-expression context is deprecated"
        ):
            self.assert_compile(
                select([table1.c.myid]).where(s > table1.c.myid),
                "SELECT mytable.myid FROM mytable WHERE "
                "mytable.myid < (SELECT mytable.myid FROM "
                "mytable)",
            )
开发者ID:monetate,项目名称:sqlalchemy,代码行数:56,代码来源:test_deprecations.py

示例4: test_legacy_typemap

    def test_legacy_typemap(self):
        table1 = table(
            "mytable",
            column("myid", Integer),
            column("name", String),
            column("description", String),
        )
        with testing.expect_deprecated(
            "The text.typemap parameter is deprecated"
        ):
            t = text(
                "select id, name from user",
                typemap=dict(id=Integer, name=String),
            )

        stmt = select([table1.c.myid]).select_from(
            table1.join(t, table1.c.myid == t.c.id)
        )
        compiled = stmt.compile()
        eq_(
            compiled._create_result_map(),
            {
                "myid": (
                    "myid",
                    (table1.c.myid, "myid", "myid"),
                    table1.c.myid.type,
                )
            },
        )
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:29,代码来源:test_deprecations.py

示例5: test_set_parse

    def test_set_parse(self):
        with testing.expect_deprecated("Manually quoting SET value literals"):
            set_table = Table(
                "mysql_set",
                self.metadata,
                Column("e1", mysql.SET("'a'")),
                Column("e2", mysql.SET("''")),
                Column("e3", mysql.SET("a")),
                Column("e4", mysql.SET("")),
                Column("e5", mysql.SET("'a'", "''")),
                Column("e6", mysql.SET("''", "'a'")),
                Column("e7", mysql.SET("''", "'''a'''", "'b''b'", "''''")),
            )

        for col in set_table.c:
            self.assert_(repr(col))

        set_table.create()

        # don't want any warnings on reflection
        reflected = Table("mysql_set", MetaData(testing.db), autoload=True)
        for t in set_table, reflected:
            eq_(t.c.e1.type.values, ("a",))
            eq_(t.c.e2.type.values, ("",))
            eq_(t.c.e3.type.values, ("a",))
            eq_(t.c.e4.type.values, ("",))
            eq_(t.c.e5.type.values, ("a", ""))
            eq_(t.c.e6.type.values, ("", "a"))
            eq_(t.c.e7.type.values, ("", "'a'", "b'b", "'"))
开发者ID:Julian,项目名称:sqlalchemy,代码行数:29,代码来源:test_types.py

示例6: test_set_parse

    def test_set_parse(self):
        with testing.expect_deprecated('Manually quoting SET value literals'):
            set_table = Table(
                'mysql_set', self.metadata,
                Column('e1', mysql.SET("'a'")),
                Column('e2', mysql.SET("''", retrieve_as_bitwise=True)),
                Column('e3', mysql.SET('a')),
                Column('e4', mysql.SET('', retrieve_as_bitwise=True)),
                Column('e5', mysql.SET("'a'", "''", retrieve_as_bitwise=True)),
                Column('e6', mysql.SET("''", "'a'", retrieve_as_bitwise=True)),
                Column('e7', mysql.SET(
                    "''", "'''a'''", "'b''b'", "''''",
                    retrieve_as_bitwise=True)))

        for col in set_table.c:
            self.assert_(repr(col))

        set_table.create()

        # don't want any warnings on reflection
        reflected = Table('mysql_set', MetaData(testing.db),
                          autoload=True)
        for t in set_table, reflected:
            eq_(t.c.e1.type.values, ("a",))
            eq_(t.c.e2.type.values, ("",))
            eq_(t.c.e3.type.values, ("a",))
            eq_(t.c.e4.type.values, ("",))
            eq_(t.c.e5.type.values, ("a", ""))
            eq_(t.c.e6.type.values, ("", "a"))
            eq_(t.c.e7.type.values, ("", "'a'", "b'b", "'"))
开发者ID:gencer,项目名称:sqlalchemy,代码行数:30,代码来源:test_types.py

示例7: test_enum_parse

    def test_enum_parse(self):

        with testing.expect_deprecated('Manually quoting ENUM value literals'):
            enum_table = Table(
                'mysql_enum', self.metadata,
                Column('e1', mysql.ENUM("'a'")),
                Column('e2', mysql.ENUM("''")),
                Column('e3', mysql.ENUM('a')),
                Column('e4', mysql.ENUM('')),
                Column('e5', mysql.ENUM("'a'", "''")),
                Column('e6', mysql.ENUM("''", "'a'")),
                Column('e7', mysql.ENUM("''", "'''a'''", "'b''b'", "''''")))

        for col in enum_table.c:
            self.assert_(repr(col))

        enum_table.create()
        reflected = Table('mysql_enum', MetaData(testing.db),
                          autoload=True)
        for t in enum_table, reflected:
            eq_(t.c.e1.type.enums, ["a"])
            eq_(t.c.e2.type.enums, [""])
            eq_(t.c.e3.type.enums, ["a"])
            eq_(t.c.e4.type.enums, [""])
            eq_(t.c.e5.type.enums, ["a", ""])
            eq_(t.c.e6.type.enums, ["", "a"])
            eq_(t.c.e7.type.enums, ["", "'a'", "b'b", "'"])
开发者ID:gencer,项目名称:sqlalchemy,代码行数:27,代码来源:test_types.py

示例8: test_deprecated_dialect_name_still_loads

 def test_deprecated_dialect_name_still_loads(self):
     dialects.registry.clear()
     with expect_deprecated(
         "The 'postgres' dialect name " "has been renamed to 'postgresql'"
     ):
         dialect = url.URL("postgres").get_dialect()
     is_(dialect, postgresql.dialect)
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:7,代码来源:test_dialect.py

示例9: test_enum_parse

    def test_enum_parse(self):

        with testing.expect_deprecated("Manually quoting ENUM value literals"):
            enum_table = Table(
                "mysql_enum",
                self.metadata,
                Column("e1", mysql.ENUM("'a'")),
                Column("e2", mysql.ENUM("''")),
                Column("e3", mysql.ENUM("a")),
                Column("e4", mysql.ENUM("")),
                Column("e5", mysql.ENUM("'a'", "''")),
                Column("e6", mysql.ENUM("''", "'a'")),
                Column("e7", mysql.ENUM("''", "'''a'''", "'b''b'", "''''")),
            )

        for col in enum_table.c:
            self.assert_(repr(col))

        enum_table.create()
        reflected = Table("mysql_enum", MetaData(testing.db), autoload=True)
        for t in enum_table, reflected:
            eq_(t.c.e1.type.enums, ("a",))
            eq_(t.c.e2.type.enums, ("",))
            eq_(t.c.e3.type.enums, ("a",))
            eq_(t.c.e4.type.enums, ("",))
            eq_(t.c.e5.type.enums, ("a", ""))
            eq_(t.c.e6.type.enums, ("", "a"))
            eq_(t.c.e7.type.enums, ("", "'a'", "b'b", "'"))
开发者ID:Julian,项目名称:sqlalchemy,代码行数:28,代码来源:test_types.py

示例10: test_as_scalar

    def test_as_scalar(self):
        with testing.expect_deprecated(
            r"The SelectBase.as_scalar\(\) method is deprecated and "
            "will be removed in a future release."
        ):
            stmt = select([table1.c.myid]).as_scalar()

        is_true(stmt.compare(select([table1.c.myid]).scalar_subquery()))
开发者ID:monetate,项目名称:sqlalchemy,代码行数:8,代码来源:test_deprecations.py

示例11: test_enum

    def test_enum(self):
        """Exercise the ENUM type."""

        with testing.expect_deprecated('Manually quoting ENUM value literals'):
            e1, e2 = mysql.ENUM("'a'", "'b'"), mysql.ENUM("'a'", "'b'")
            e3 = mysql.ENUM("'a'", "'b'", strict=True)
            e4 = mysql.ENUM("'a'", "'b'", strict=True)

        enum_table = Table('mysql_enum', self.metadata,
            Column('e1', e1),
            Column('e2', e2, nullable=False),
            Column('e2generic', Enum("a", "b"), nullable=False),
            Column('e3', e3),
            Column('e4', e4,
                   nullable=False),
            Column('e5', mysql.ENUM("a", "b")),
            Column('e5generic', Enum("a", "b")),
            Column('e6', mysql.ENUM("'a'", "b")),
            )

        eq_(colspec(enum_table.c.e1),
                       "e1 ENUM('a','b')")
        eq_(colspec(enum_table.c.e2),
                       "e2 ENUM('a','b') NOT NULL")
        eq_(colspec(enum_table.c.e2generic),
                      "e2generic ENUM('a','b') NOT NULL")
        eq_(colspec(enum_table.c.e3),
                       "e3 ENUM('a','b')")
        eq_(colspec(enum_table.c.e4),
                       "e4 ENUM('a','b') NOT NULL")
        eq_(colspec(enum_table.c.e5),
                       "e5 ENUM('a','b')")
        eq_(colspec(enum_table.c.e5generic),
                      "e5generic ENUM('a','b')")
        eq_(colspec(enum_table.c.e6),
                       "e6 ENUM('''a''','b')")
        enum_table.create()

        assert_raises(exc.DBAPIError, enum_table.insert().execute,
                        e1=None, e2=None, e3=None, e4=None)

        assert_raises(exc.StatementError, enum_table.insert().execute,
                                        e1='c', e2='c', e2generic='c', e3='c',
                                        e4='c', e5='c', e5generic='c', e6='c')

        enum_table.insert().execute()
        enum_table.insert().execute(e1='a', e2='a', e2generic='a', e3='a',
                                    e4='a', e5='a', e5generic='a', e6="'a'")
        enum_table.insert().execute(e1='b', e2='b', e2generic='b', e3='b',
                                    e4='b', e5='b', e5generic='b', e6='b')

        res = enum_table.select().execute().fetchall()

        expected = [(None, 'a', 'a', None, 'a', None, None, None),
                    ('a', 'a', 'a', 'a', 'a', 'a', 'a', "'a'"),
                    ('b', 'b', 'b', 'b', 'b', 'b', 'b', 'b')]

        eq_(res, expected)
开发者ID:SmartTeleMax,项目名称:sqlalchemy,代码行数:58,代码来源:test_types.py

示例12: test_threaded_deprecated_at_dialect_level

 def test_threaded_deprecated_at_dialect_level(self):
     with testing.expect_deprecated(
         "The 'threaded' parameter to the cx_oracle dialect"
     ):
         dialect = cx_oracle.dialect(threaded=False)
     arg, kw = dialect.create_connect_args(
         url.make_url("oracle+cx_oracle://scott:[email protected]")
     )
     eq_(kw["threaded"], False)
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:9,代码来源:test_dialect.py

示例13: test_enum

    def test_enum(self):
        """Exercise the ENUM type."""

        with testing.expect_deprecated("Manually quoting ENUM value literals"):
            e1, e2 = mysql.ENUM("'a'", "'b'"), mysql.ENUM("'a'", "'b'")

        enum_table = Table(
            "mysql_enum",
            self.metadata,
            Column("e1", e1),
            Column("e2", e2, nullable=False),
            Column("e2generic", Enum("a", "b"), nullable=False),
            Column("e3", mysql.ENUM("'a'", "'b'", strict=True)),
            Column("e4", mysql.ENUM("'a'", "'b'", strict=True), nullable=False),
            Column("e5", mysql.ENUM("a", "b")),
            Column("e5generic", Enum("a", "b")),
            Column("e6", mysql.ENUM("'a'", "b")),
        )

        eq_(colspec(enum_table.c.e1), "e1 ENUM('a','b')")
        eq_(colspec(enum_table.c.e2), "e2 ENUM('a','b') NOT NULL")
        eq_(colspec(enum_table.c.e2generic), "e2generic ENUM('a','b') NOT NULL")
        eq_(colspec(enum_table.c.e3), "e3 ENUM('a','b')")
        eq_(colspec(enum_table.c.e4), "e4 ENUM('a','b') NOT NULL")
        eq_(colspec(enum_table.c.e5), "e5 ENUM('a','b')")
        eq_(colspec(enum_table.c.e5generic), "e5generic ENUM('a','b')")
        eq_(colspec(enum_table.c.e6), "e6 ENUM('''a''','b')")
        enum_table.create()

        assert_raises(exc.DBAPIError, enum_table.insert().execute, e1=None, e2=None, e3=None, e4=None)

        assert_raises(
            exc.StatementError,
            enum_table.insert().execute,
            e1="c",
            e2="c",
            e2generic="c",
            e3="c",
            e4="c",
            e5="c",
            e5generic="c",
            e6="c",
        )

        enum_table.insert().execute()
        enum_table.insert().execute(e1="a", e2="a", e2generic="a", e3="a", e4="a", e5="a", e5generic="a", e6="'a'")
        enum_table.insert().execute(e1="b", e2="b", e2generic="b", e3="b", e4="b", e5="b", e5generic="b", e6="b")

        res = enum_table.select().execute().fetchall()

        expected = [
            (None, "a", "a", None, "a", None, None, None),
            ("a", "a", "a", "a", "a", "a", "a", "'a'"),
            ("b", "b", "b", "b", "b", "b", "b", "b"),
        ]

        eq_(res, expected)
开发者ID:Julian,项目名称:sqlalchemy,代码行数:57,代码来源:test_types.py

示例14: test_labeled_role

    def test_labeled_role(self):
        stmt = select([table1.c.myid])

        with testing.expect_deprecated(
            "coercing SELECT object to scalar "
            "subquery in a column-expression context is deprecated"
        ):
            coerced = coercions.expect(roles.LabeledColumnExprRole, stmt)
            is_true(coerced.compare(stmt.scalar_subquery().label(None)))

        with testing.expect_deprecated(
            "coercing SELECT object to scalar "
            "subquery in a column-expression context is deprecated"
        ):
            coerced = coercions.expect(
                roles.LabeledColumnExprRole, stmt.alias()
            )
            is_true(coerced.compare(stmt.scalar_subquery().label(None)))
开发者ID:monetate,项目名称:sqlalchemy,代码行数:18,代码来源:test_deprecations.py

示例15: setup_mappers

    def setup_mappers(cls):
        foo = cls.tables.foo

        mapper(Foo, foo)
        with testing.expect_deprecated(
            "The mapper.non_primary parameter is deprecated"
        ):
            mapper(
                Foo, foo, non_primary=True, properties={"foo_bar": foo.c.data}
            )
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:10,代码来源:test_deprecations.py


注:本文中的sqlalchemy.testing.expect_deprecated函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。