本文整理汇总了Python中spec.eq_函数的典型用法代码示例。如果您正苦于以下问题:Python eq_函数的具体用法?Python eq_怎么用?Python eq_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eq_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: positionalness_and_optionalness_stick_together
def positionalness_and_optionalness_stick_together(self):
# TODO: but do these even make sense on the same argument? For now,
# best to have a nonsensical test than a missing one...
eq_(
repr(Argument('name', optional=True, positional=True)),
"<Argument: name *?>",
)
示例2: multiple_short_flags_adjacent
def multiple_short_flags_adjacent(self):
"mytask -bv (and inverse)"
for args in ('-bv', '-vb'):
r = self._parse("mytask %s" % args)
a = r[0].args
eq_(a.b.value, True)
eq_(a.v.value, True)
示例3: core_help_option_prints_core_help
def core_help_option_prints_core_help(self):
# TODO: change dynamically based on parser contents?
# e.g. no core args == no [--core-opts],
# no tasks == no task stuff?
# NOTE: test will trigger default pty size of 80x24, so the below
# string is formatted appropriately.
# TODO: add more unit-y tests for specific behaviors:
# * fill terminal w/ columns + spacing
# * line-wrap help text in its own column
expected = """
Usage: inv[oke] [--core-opts] task1 [--task1-opts] ... taskN [--taskN-opts]
Core options:
--no-dedupe Disable task deduplication.
-c STRING, --collection=STRING Specify collection name to load. May be
given >1 time.
-e, --echo Echo executed commands before running.
-h [STRING], --help[=STRING] Show core or per-task help and exit.
-H STRING, --hide=STRING Set default value of run()'s 'hide' kwarg.
-l, --list List available tasks.
-p, --pty Use a pty when executing shell commands.
-r STRING, --root=STRING Change root directory used for finding task
modules.
-V, --version Show version and exit.
-w, --warn-only Warn, instead of failing, when shell
commands fail.
""".lstrip()
r1 = run("inv -h", hide='out')
r2 = run("inv --help", hide='out')
eq_(r1.stdout, expected)
eq_(r2.stdout, expected)
示例4: submodule_names_are_stripped_to_last_chunk
def submodule_names_are_stripped_to_last_chunk(self):
with support_path():
from package import module
c = Collection.from_module(module)
eq_(module.__name__, 'package.module')
eq_(c.name, 'module')
assert 'mytask' in c # Sanity
示例5: default_tasks
def default_tasks(self):
# sub-ns default task display as "real.name (collection name)"
expected = self._listing(
'top_level (othertop)',
'sub.sub_task (sub, sub.othersub)',
)
eq_(run("invoke -c explicit_root --list").stdout, expected)
示例6: searches_towards_root_of_filesystem
def searches_towards_root_of_filesystem(self):
# Loaded while root is in same dir as .py
directly = self.l.load('foo')
# Loaded while root is multiple dirs deeper than the .py
deep = os.path.join(support, 'ignoreme', 'ignoremetoo')
indirectly = FSLoader(start=deep).load('foo')
eq_(directly, indirectly)
示例7: arguments_which_take_values_get_defaults_overridden_correctly
def arguments_which_take_values_get_defaults_overridden_correctly(self):
args = (Argument('arg', kind=str), Argument('arg2', kind=int))
c = Context('mytask', args=args)
argv = ['mytask', '--arg', 'myval', '--arg2', '25']
result = Parser((c,)).parse_argv(argv)
eq_(result[0].args['arg'].value, 'myval')
eq_(result[0].args['arg2'].value, 25)
示例8: unsets_aliases
def unsets_aliases(self):
ad = AliasDict()
ad['realkey'] = 'value'
ad.alias('myalias', to='realkey')
eq_(ad['myalias'], 'value')
ad.unalias('myalias')
assert 'myalias' not in ad
示例9: comparison_looks_at_merged_config
def comparison_looks_at_merged_config(self):
c1 = Config(defaults={'foo': {'bar': 'biz'}})
# Empty defaults to suppress global_defaults
c2 = Config(defaults={}, overrides={'foo': {'bar': 'biz'}})
ok_(c1 is not c2)
ok_(c1._defaults != c2._defaults)
eq_(c1, c2)
示例10: can_clone_into_a_subclass
def can_clone_into_a_subclass(self):
orig = Call(self.task)
class MyCall(Call):
pass
clone = orig.clone(into=MyCall)
eq_(clone, orig)
ok_(isinstance(clone, MyCall))
示例11: deletion_is_recursive
def deletion_is_recursive(self):
ad = self._recursive_aliases()
del ad['alias2']
assert 'realkey' not in ad
ad['realkey'] = 'newvalue'
assert 'alias1' in ad
eq_(ad['alias1'], 'newvalue')
示例12: multiple_short_flags_adjacent
def multiple_short_flags_adjacent(self):
"mytask -bv (and inverse)"
for args in ("-bv", "-vb"):
r = self._parse("mytask {0}".format(args))
a = r[0].args
eq_(a.b.value, True)
eq_(a.v.value, True)
示例13: ensure_deepcopy_works
def ensure_deepcopy_works(self):
ad = AttributeDict()
ad['foo'] = 'bar'
eq_(ad.foo, 'bar')
ad2 = copy.deepcopy(ad)
ad2.foo = 'biz'
assert ad2.foo != ad.foo
示例14: simple_command
def simple_command(self):
group = Group('localhost', '127.0.0.1')
result = group.run('echo foo', hide=True)
eq_(
[x.stdout.strip() for x in result.values()],
['foo', 'foo'],
)
示例15: return_code_in_result
def return_code_in_result(self):
"""
Result has .return_code (and .exited) containing exit code int
"""
r = run(self.out, hide='both')
eq_(r.return_code, 0)
eq_(r.exited, 0)