本文整理汇总了Python中tests.eq_函数的典型用法代码示例。如果您正苦于以下问题:Python eq_函数的具体用法?Python eq_怎么用?Python eq_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eq_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_render_quoted_server_default
def test_render_quoted_server_default(self):
eq_(
autogenerate._render_server_default(
"nextval('group_to_perm_group_to_perm_id_seq'::regclass)",
self.autogen_context),
'"nextval(\'group_to_perm_group_to_perm_id_seq\'::regclass)"'
)
示例2: test_clear
def test_clear(self):
db = sqlsoup.SQLSoup(engine)
eq_(db.loans.count(), 1)
_ = db.loans.insert(book_id=1, user_name='Bhargan Basepair')
db.expunge_all()
db.flush()
eq_(db.loans.count(), 1)
示例3: test_globlookup
def test_globlookup(self):
# Create temporary files equivalent to those used in test_strlookup
tmp = mkdtemp()
chars = ("a", "b", "c")
for l1 in chars:
os.mkdir(os.path.join(tmp, l1))
for l2 in chars:
os.mkdir(os.path.join(tmp, l1, l2))
for l3 in chars:
f = os.path.join(tmp, l1, l2, l3)
with open(f, "w") as fh:
fh.write(f)
# Test the lookup
lookup = partial(globlookup, root=tmp)
eq_(list(lookup("a/a/*")), ["a/a/a", "a/a/b", "a/a/c"])
eq_(list(lookup("a/*/a")), ["a/a/a", "a/b/a", "a/c/a"])
eq_(list(lookup("*/a/a")), ["a/a/a", "b/a/a", "c/a/a"])
eq_(list(lookup("a/*")), [
"a/a/a", "a/a/b", "a/a/c",
"a/b/a", "a/b/b", "a/b/c",
"a/c/a", "a/c/b", "a/c/c",
])
# Test the lookup within set_evil
eq_(set_evil("a/* = */a", lookup), set(["a/a/a", "a/b/a", "a/c/a"]))
示例4: test_render_custom
def test_render_custom(self):
def render(type_, obj, context):
if type_ == "foreign_key":
return None
if type_ == "column":
if obj.name == "y":
return None
else:
return "col(%s)" % obj.name
return "render:%s" % type_
autogen_context = {"opts": {
'render_item': render,
'alembic_module_prefix': 'sa.'
}}
t = Table('t', MetaData(),
Column('x', Integer),
Column('y', Integer),
PrimaryKeyConstraint('x'),
ForeignKeyConstraint(['x'], ['y'])
)
result = autogenerate._add_table(
t, autogen_context
)
eq_(
result, """sa.create_table('t',
col(x),
render:primary_key\n)"""
)
示例5: test_lookup_legacy
def test_lookup_legacy(self):
self.cfg.set_main_option("file_template", "%%(rev)s")
script = ScriptDirectory.from_config(self.cfg)
a = util.rev_id()
script.generate_revision(a, None, refresh=True)
write_script(
script,
a,
"""
down_revision = None
from alembic import op
def upgrade():
op.execute("CREATE TABLE foo(id integer)")
def downgrade():
op.execute("DROP TABLE foo")
""",
)
script = ScriptDirectory.from_config(self.cfg)
rev = script._get_rev(a)
eq_(rev.revision, a)
eq_(os.path.basename(rev.path), "%s.py" % a)
示例6: test_set_evil_op_opposing
def test_set_evil_op_opposing(self):
try:
set_evil("a > < b", lambda t: set(), self.left_right_ops())
except SyntaxError as e:
eq_(e.args[0], "Operators cannot be beside one another if they "
"act on expressions facing one-another.")
set_evil("a <> <> b", lambda t: set(), self.left_right_ops())
示例7: test_option
def test_option(self):
self.cfg.set_main_option("file_template", "myfile_%%(slug)s")
script = ScriptDirectory.from_config(self.cfg)
a = util.rev_id()
script.generate_revision(a, "some message", refresh=True)
write_script(
script,
a,
"""
revision = '%s'
down_revision = None
from alembic import op
def upgrade():
op.execute("CREATE TABLE foo(id integer)")
def downgrade():
op.execute("DROP TABLE foo")
"""
% a,
)
script = ScriptDirectory.from_config(self.cfg)
rev = script._get_rev(a)
eq_(rev.revision, a)
eq_(os.path.basename(rev.path), "myfile_some_message.py")
示例8: test_args_propagate
def test_args_propagate(self):
config = _no_sql_testing_config()
script = ScriptDirectory.from_config(config)
template_args = {"x": "x1", "y": "y1", "z": "z1"}
env = EnvironmentContext(config, script, template_args=template_args)
env.configure(dialect_name="sqlite", template_args={"y": "y2", "q": "q1"})
eq_(template_args, {"x": "x1", "y": "y2", "z": "z1", "q": "q1"})
示例9: test_render_drop_table_w_schema
def test_render_drop_table_w_schema(self):
eq_(
autogenerate._drop_table(
Table("sometable", MetaData(), schema='foo'),
self.autogen_context),
"op.drop_table('sometable', schema='foo')"
)
示例10: test_render_nothing
def test_render_nothing(self):
context = MigrationContext.configure(
connection=self.bind.connect(),
opts={
'compare_type': True,
'compare_server_default': True,
'target_metadata': self.m1,
'upgrade_token': "upgrades",
'downgrade_token': "downgrades",
'alembic_module_prefix': 'op.',
'sqlalchemy_module_prefix': 'sa.',
}
)
template_args = {}
autogenerate._produce_migration_diffs(context, template_args, set(),
include_symbol=lambda name, schema: False
)
eq_(re.sub(r"u'", "'", template_args['upgrades']),
"""### commands auto generated by Alembic - please adjust! ###
pass
### end Alembic commands ###""")
eq_(re.sub(r"u'", "'", template_args['downgrades']),
"""### commands auto generated by Alembic - please adjust! ###
pass
### end Alembic commands ###""")
示例11: test_xcpp_matlab
def test_xcpp_matlab():
"""[XCPP-MATLAB]: """
exec_cmd('excentury xc_test.xcpp to matlab --force')
cmd = 'matlab -nodisplay -nosplash'
run_cmd("%s < matlab/xc_test.m > /dev/null" % cmd, "", "")
data = load_file('tmp.xc')
eq_(data['x'], 4, "Failed...")
eq_(data['y'], 27, "Failed...")
示例12: test_set_evil_op_right_missing
def test_set_evil_op_right_missing(self):
try:
set_evil("a >", lambda t: set(), self.left_right_ops())
except SyntaxError as e:
eq_(e.args[0], "Operators which act on expressions to their "
"right or both sides cannot be at the end of "
"an expression.")
raise e
示例13: test_set_evil_op_left_missing
def test_set_evil_op_left_missing(self):
try:
set_evil("< b", lambda t: set(), self.left_right_ops())
except TypeError as e:
eq_(e.args[0], "Operators which act on expressions to their "
"left or both sides cannot be at the beginning "
"of an expression.")
raise e
示例14: test_standalone_op
def test_standalone_op():
eng, buf = capture_db()
env = MigrationContext.configure(eng)
op = Operations(env)
op.alter_column("t", "c", nullable=True)
eq_(buf, ['ALTER TABLE t ALTER COLUMN c DROP NOT NULL'])
示例15: test_config_no_file_section_option
def test_config_no_file_section_option():
cfg = config.Config()
cfg.set_section_option("foo", "url", "postgresql://foo/bar")
eq_(cfg.get_section_option("foo", "url"), "postgresql://foo/bar")
cfg.set_section_option("foo", "echo", "True")
eq_(cfg.get_section_option("foo", "echo"), "True")