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


Python testing.in_函数代码示例

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


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

示例1: test_row_case_sensitive_unoptimized

    def test_row_case_sensitive_unoptimized(self):
        ins_db = engines.testing_engine(options={"case_sensitive": True})
        row = ins_db.execute(
            select([
                literal_column("1").label("case_insensitive"),
                literal_column("2").label("CaseSensitive"),
                text("3 AS screw_up_the_cols")
            ])
        ).first()

        eq_(
            list(row.keys()),
            ["case_insensitive", "CaseSensitive", "screw_up_the_cols"])

        in_("case_insensitive", row._keymap)
        in_("CaseSensitive", row._keymap)
        not_in_("casesensitive", row._keymap)

        eq_(row["case_insensitive"], 1)
        eq_(row["CaseSensitive"], 2)
        eq_(row["screw_up_the_cols"], 3)

        assert_raises(KeyError, lambda: row["Case_insensitive"])
        assert_raises(KeyError, lambda: row["casesensitive"])
        assert_raises(KeyError, lambda: row["screw_UP_the_cols"])
开发者ID:mattastica,项目名称:sqlalchemy,代码行数:25,代码来源:test_resultset.py

示例2: test_column_label_overlap_fallback

    def test_column_label_overlap_fallback(self):
        content = Table(
            'content', self.metadata,
            Column('type', String(30)),
        )
        bar = Table(
            'bar', self.metadata,
            Column('content_type', String(30))
        )
        self.metadata.create_all(testing.db)
        testing.db.execute(content.insert().values(type="t1"))

        row = testing.db.execute(content.select(use_labels=True)).first()
        in_(content.c.type, row)
        not_in_(bar.c.content_type, row)
        in_(sql.column('content_type'), row)

        row = testing.db.execute(
            select([content.c.type.label("content_type")])).first()
        in_(content.c.type, row)

        not_in_(bar.c.content_type, row)

        in_(sql.column('content_type'), row)

        row = testing.db.execute(select([func.now().label("content_type")])). \
            first()
        not_in_(content.c.type, row)

        not_in_(bar.c.content_type, row)

        in_(sql.column('content_type'), row)
开发者ID:mattastica,项目名称:sqlalchemy,代码行数:32,代码来源:test_resultset.py

示例3: test_row_case_sensitive

    def test_row_case_sensitive(self):
        row = testing.db.execute(
            select([
                literal_column("1").label("case_insensitive"),
                literal_column("2").label("CaseSensitive")
            ])
        ).first()

        eq_(list(row.keys()), ["case_insensitive", "CaseSensitive"])

        in_("case_insensitive", row._keymap)
        in_("CaseSensitive", row._keymap)
        not_in_("casesensitive", row._keymap)

        eq_(row["case_insensitive"], 1)
        eq_(row["CaseSensitive"], 2)

        assert_raises(
            KeyError,
            lambda: row["Case_insensitive"]
        )
        assert_raises(
            KeyError,
            lambda: row["casesensitive"]
        )
开发者ID:mattastica,项目名称:sqlalchemy,代码行数:25,代码来源:test_resultset.py

示例4: test_modified

    def test_modified(self):

        Json = self.classes.Json
        s = Session(testing.db)

        j = Json(json={})
        s.add(j)
        s.commit()

        i = inspect(j)
        is_(i.modified, False)
        in_('json', i.unmodified)

        j.other = 42

        is_(i.modified, True)
        not_in_('json', i.unmodified)
开发者ID:MarSoft,项目名称:sqlalchemy,代码行数:17,代码来源:test_indexable.py

示例5: test_columnclause_schema_column_two

    def test_columnclause_schema_column_two(self):
        keyed2 = self.tables.keyed2

        a, b = sql.column('a'), sql.column('b')
        stmt = select([keyed2.c.a, keyed2.c.b])
        row = testing.db.execute(stmt).first()

        in_(keyed2.c.a, row)
        in_(keyed2.c.b, row)
        in_(a, row)
        in_(b, row)
开发者ID:mattastica,项目名称:sqlalchemy,代码行数:11,代码来源:test_resultset.py

示例6: test_columnclause_schema_column_five

    def test_columnclause_schema_column_five(self):
        keyed2 = self.tables.keyed2

        # this is also addressed by [ticket:2932]

        stmt = text("select a AS keyed2_a, b AS keyed2_b from keyed2").columns(
            keyed2_a=CHAR, keyed2_b=CHAR)
        row = testing.db.execute(stmt).first()

        in_(keyed2.c.a, row)
        in_(keyed2.c.b, row)
        in_(stmt.c.keyed2_a, row)
        in_(stmt.c.keyed2_b, row)
开发者ID:mattastica,项目名称:sqlalchemy,代码行数:13,代码来源:test_resultset.py

示例7: test_columnclause_schema_column_one

    def test_columnclause_schema_column_one(self):
        keyed2 = self.tables.keyed2

        # this is addressed by [ticket:2932]
        # ColumnClause._compare_name_for_result allows the
        # columns which the statement is against to be lightweight
        # cols, which results in a more liberal comparison scheme
        a, b = sql.column('a'), sql.column('b')
        stmt = select([a, b]).select_from(table("keyed2"))
        row = testing.db.execute(stmt).first()

        in_(keyed2.c.a, row)
        in_(keyed2.c.b, row)
        in_(a, row)
        in_(b, row)
开发者ID:mattastica,项目名称:sqlalchemy,代码行数:15,代码来源:test_resultset.py

示例8: test_max_ident_in_varchar_not_present

    def test_max_ident_in_varchar_not_present(self):
        """test [ticket:3504].

        Here we are testing not just that the "max" token comes back
        as None, but also that these types accept "max" as the value
        of "length" on construction, which isn't a directly documented
        pattern however is likely in common use.

        """
        metadata = self.metadata

        Table(
            't', metadata,
            Column('t1', types.String),
            Column('t2', types.Text('max')),
            Column('t3', types.Text('max')),
            Column('t4', types.LargeBinary('max')),
            Column('t5', types.VARBINARY('max')),
        )
        metadata.create_all()
        for col in inspect(testing.db).get_columns('t'):
            is_(col['type'].length, None)
            in_('max', str(col['type'].compile(dialect=testing.db.dialect)))
开发者ID:anti-social,项目名称:sqlalchemy,代码行数:23,代码来源:test_reflection.py

示例9: test_row_case_insensitive

    def test_row_case_insensitive(self):
        ins_db = engines.testing_engine(options={"case_sensitive": False})
        row = ins_db.execute(
            select([
                literal_column("1").label("case_insensitive"),
                literal_column("2").label("CaseSensitive")
            ])
        ).first()

        eq_(list(row.keys()), ["case_insensitive", "CaseSensitive"])

        in_("case_insensitive", row._keymap)
        in_("CaseSensitive", row._keymap)
        in_("casesensitive", row._keymap)

        eq_(row["case_insensitive"], 1)
        eq_(row["CaseSensitive"], 2)
        eq_(row["Case_insensitive"], 1)
        eq_(row["casesensitive"], 2)
开发者ID:mattastica,项目名称:sqlalchemy,代码行数:19,代码来源:test_resultset.py

示例10: test_columnclause_schema_column_four

    def test_columnclause_schema_column_four(self):
        keyed2 = self.tables.keyed2

        # this is also addressed by [ticket:2932]

        a, b = sql.column('keyed2_a'), sql.column('keyed2_b')
        stmt = text("select a AS keyed2_a, b AS keyed2_b from keyed2").columns(
            a, b)
        row = testing.db.execute(stmt).first()

        in_(keyed2.c.a, row)
        in_(keyed2.c.b, row)
        in_(a, row)
        in_(b, row)
        in_(stmt.c.keyed2_a, row)
        in_(stmt.c.keyed2_b, row)
开发者ID:mattastica,项目名称:sqlalchemy,代码行数:16,代码来源:test_resultset.py

示例11: test_column_label_overlap_fallback_2

 def test_column_label_overlap_fallback_2(self):
     content, bar = self.tables.content, self.tables.bar
     row = testing.db.execute(content.select(use_labels=True)).first()
     in_(content.c.type, row)
     not_in_(bar.c.content_type, row)
     not_in_(sql.column('content_type'), row)
开发者ID:mattastica,项目名称:sqlalchemy,代码行数:6,代码来源:test_resultset.py


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