spec.eq_

Here are the examples of the python api spec.eq_ taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

199 Examples 7

Example 1

Project: invoke Source File: config.py
        def project_overrides_systemwide(self):
            c = Config(
                system_prefix=join(CONFIGS_PATH, 'json', 'invoke'),
                project_home=join(CONFIGS_PATH, 'yaml'),
            )
            eq_(c.hooray, 'yaml')

Example 2

Project: invoke Source File: config.py
        def runtime_overrides_systemwide(self):
            c = Config(
                runtime_path=join(CONFIGS_PATH, 'json', 'invoke.json'),
                system_prefix=join(CONFIGS_PATH, 'yaml', 'invoke'),
            )
            eq_(c.hooray, 'json')

Example 3

Project: invoke Source File: collection.py
        def subcollection_paths_may_be_dotted(self):
            leaf = Collection('leaf', self.task)
            leaf.configure({'key': 'leaf-value'})
            middle = Collection('middle', leaf)
            root = Collection('root', middle)
            eq_(root.configuration('middle.leaf.task'), {'key': 'leaf-value'})

Example 4

Project: invoke Source File: config.py
            def boolean_type_inputs_with_non_boolean_defaults(self):
                for input_ in ('0', '1', '', 'meh', 'false'):
                    os.environ['FOO'] = input_
                    c = Config(defaults={'foo': 'bar'})
                    c.load_shell_env()
                    eq_(c.foo, input_)

Example 5

Project: invoke Source File: config.py
        def subkeys_get_merged_not_overwritten(self):
            # Ensures nested keys merge deeply instead of shallowly.
            defaults = {'foo': {'bar': 'baz'}}
            overrides = {'foo': {'notbar': 'notbaz'}}
            c = Config(defaults=defaults, overrides=overrides)
            eq_(c.foo.notbar, 'notbaz')
            eq_(c.foo.bar, 'baz')

Example 6

Project: invoke Source File: collection.py
        def configure_merging_is_recursive_for_nested_dicts(self):
            self.root.configure({'foo': 'bar', 'biz': {'baz': 'boz'}})
            self.root.configure({'biz': {'otherbaz': 'otherboz'}})
            c = self.root.configuration()
            eq_(c['biz']['baz'], 'boz')
            eq_(c['biz']['otherbaz'], 'otherboz')

Example 7

Project: invoke Source File: config.py
        def env_vars_override_systemwide(self):
            os.environ['HOORAY'] = 'env'
            c = Config(
                system_prefix=join(CONFIGS_PATH, 'yaml', 'invoke'),
            )
            c.load_shell_env()
            eq_(c.hooray, 'env')

Example 8

Project: invoke Source File: cli.py
    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)

Example 9

Project: invoke Source File: config.py
        def json_prevents_python(self):
            c = Config(
                system_prefix=join(CONFIGS_PATH, 'json-and-python', 'invoke'))
            ok_('python_only' not in c)
            ok_('json-only' in c)
            eq_(c.shared, 'json-value')

Example 10

Project: invoke Source File: collection.py
        def initial_string_arg_meshes_with_varargs_and_kwargs(self):
            @task
            def task1(ctx):
                pass
            @task
            def task2(ctx):
                pass
            sub = Collection('sub')
            ns = Collection('root', task1, sub, sometask=task2)
            for x, y in (
                (ns.name, 'root'),
                (ns['task1'], task1),
                (ns.collections['sub'], sub),
                (ns['sometask'], task2),
            ):
                eq_(x, y)

Example 11

Project: invoke Source File: config.py
            def unicode_replaced_with_env_value(self):
                # Python 3 doesn't allow you to put 'bytes' objects into
                # os.environ, so the test makes no sense there.
                if six.PY3:
                    return
                os.environ['FOO'] = 'myunicode'
                c = Config(defaults={'foo': six.u('myoldvalue')})
                c.load_shell_env()
                eq_(c.foo, 'myunicode')
                ok_(isinstance(c.foo, str))

Example 12

Project: invoke Source File: config.py
        def supports_mutation_dict_protocols(self):
            c = Config({'foo': 'bar'})
            eq_(len(c), 1)
            eq_(c.pop('foo'), 'bar')
            eq_(len(c), 0)
            c.setdefault('biz', 'baz')
            eq_(c['biz'], 'baz')
            c['boz'] = 'buzz'
            eq_(len(c), 2)
            del c['boz']
            eq_(len(c), 1)
            ok_('boz' not in c)
            eq_(c.popitem(), ('biz', 'baz'))
            eq_(len(c), 0)
            c.update({'foo': 'bar'})
            eq_(c['foo'], 'bar')

Example 13

Project: invoke Source File: collection.py
        def specifying_default_False_overrides_task_setting(self):
            @task(default=True)
            def its_me(ctx):
                pass
            self.c.add_task(its_me, default=False)
            eq_(self.c.default, None)

Example 14

Project: invoke Source File: config.py
        def user_overrides_systemwide(self):
            c = Config(
                system_prefix=join(CONFIGS_PATH, 'yaml', 'invoke'),
                user_prefix=join(CONFIGS_PATH, 'json', 'invoke'),
            )
            eq_(c.hooray, 'json')

Example 15

Project: invoke Source File: cli.py
    def three_tasks_with_args(self):
        "mytask --boolean mytask3 --mystring foo mytask2"
        r = self._parse("mytask --boolean mytask3 --mystring foo mytask2")
        eq_(len(r), 3)
        eq_([x.name for x in r], ['mytask', 'mytask3', 'mytask2'])
        eq_(r[0].args.boolean.value, True)
        eq_(r[1].args.mystring.value, 'foo')

Example 16

Project: invoke Source File: config.py
        def env_vars_override_project(self):
            os.environ['HOORAY'] = 'env'
            c = Config(
                project_home=join(CONFIGS_PATH, 'yaml'),
            )
            c.load_shell_env()
            eq_(c.hooray, 'env')

Example 17

Project: invoke Source File: collection.py
        def parents_overwrite_children_in_path(self):
            inner = Collection('inner', self.task)
            inner.configure({'foo': 'inner'})
            self.root.add_collection(inner)
            # Before updating root collection's config, reflects inner
            eq_(self.root.configuration('inner.task')['foo'], 'inner')
            self.root.configure({'foo': 'outer'})
            # After, reflects outer (since that now overrides)
            eq_(self.root.configuration('inner.task')['foo'], 'outer')

Example 18

Project: invoke Source File: config.py
        def runtime_overrides_project(self):
            c = Config(
                runtime_path=join(CONFIGS_PATH, 'json', 'invoke.json'),
                project_home=join(CONFIGS_PATH, 'yaml'),
            )
            eq_(c.hooray, 'json')

Example 19

Project: invoke Source File: main.py
    def simple_command_with_pty(self):
        """
        Run command under PTY
        """
        # Most Unix systems should have stty, which asplodes when not run under
        # a pty, and prints useful info otherwise
        result = run('stty -a', hide=True, pty=True)
        # PTYs use \r\n, not \n, line separation
        ok_("\r\n" in result.stdout)
        eq_(result.pty, True)

Example 20

Project: invoke Source File: config.py
        def yaml_prevents_json_or_python(self):
            c = Config(
                system_prefix=join(CONFIGS_PATH, 'all-three', 'invoke'))
            ok_('json-only' not in c)
            ok_('python_only' not in c)
            ok_('yaml-only' in c)
            eq_(c.shared, 'yaml-value')

Example 21

Project: invoke Source File: config.py
        def nested_dict_values_also_allow_dual_access(self):
            # TODO: ditto
            c = Config({'foo': 'bar', 'biz': {'baz': 'boz'}})
            # Sanity check - nested doesn't somehow kill simple top level
            eq_(c.foo, 'bar')
            eq_(c['foo'], 'bar')
            # Actual check
            eq_(c.biz.baz, 'boz')
            eq_(c['biz']['baz'], 'boz')
            eq_(c.biz['baz'], 'boz')
            eq_(c['biz'].baz, 'boz')

Example 22

Project: invoke Source File: config.py
        def attr_access_has_useful_error_msg(self):
            c = Config()
            try:
                c.nope
            except AttributeError as e:
                expected = """
No attribute or config key found for 'nope'

Valid keys: ['run', 'sudo', 'tasks']

Valid real attributes: ['clone', 'from_data', 'global_defaults', 'load_collection', 'load_files', 'load_shell_env', 'merge', 'paths']
""".strip() # noqa
                eq_(str(e), expected)
            else:
                assert False, "Didn't get an AttributeError on bad key!"

Example 23

Project: invoke Source File: runners.py
        def watcher_errors_become_Failures(self):
            watcher = FailingResponder(
                pattern=r"What's the password\?",
                response="Rosebud\n",
                sentinel="You're not Citizen Kane!",
            )
            try:
                run("python -u respond_fail.py", watchers=[watcher], hide=True)
            except Failure as e:
                ok_(isinstance(e.reason, WatcherError))
                eq_(e.result.exited, None)
            else:
                assert False, "Did not raise Failure!"

Example 24

Project: invoke Source File: config.py
        def supports_readonly_dict_protocols(self):
            # Use single-keypair dict to avoid sorting problems in tests.
            c = Config({'foo': 'bar'})
            c2 = Config({'foo': 'bar'})
            ok_('foo' in c)
            ok_('foo' in c2) # mostly just to trigger loading :x
            eq_(c, c2)
            eq_(len(c), 1)
            eq_(c.get('foo'), 'bar')
            if six.PY2:
                eq_(c.has_key('foo'), True)  # noqa
                eq_(list(c.iterkeys()), ['foo'])
                eq_(list(c.itervalues()), ['bar'])
            eq_(list(c.items()), [('foo', 'bar')])
            eq_(list(six.iteritems(c)), [('foo', 'bar')])
            eq_(list(c.keys()), ['foo'])
            eq_(list(c.values()), ['bar'])

Example 25

Project: invoke Source File: collection.py
            def name_override(self):
                eq_(self.fm(self.mod).name, 'integration')
                eq_(
                    self.fm(self.mod, name='not-integration').name,
                    'not-integration'
                )

Example 26

Project: invoke Source File: config.py
            def strings_replaced_with_env_value(self):
                os.environ['FOO'] = six.u('myvalue')
                c = Config(defaults={'foo': 'myoldvalue'})
                c.load_shell_env()
                eq_(c.foo, six.u('myvalue'))
                ok_(isinstance(c.foo, six.text_type))

Example 27

Project: invoke Source File: config.py
        def string_display(self):
            "__str__ and friends"
            config = Config({'foo': 'bar'})
            eq_(str(config), "<Config: {'foo': 'bar'}>")
            if six.PY2:
                eq_(unicode(config), six.u("<Config: {'foo': 'bar'}>"))  # noqa
            eq_(repr(config), "<Config: {'foo': 'bar'}>")

Example 28

Project: invoke Source File: collection.py
        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

Example 29

Project: invoke Source File: config.py
            def booleans(self):
                for input_, result in (
                    ('0', False),
                    ('1', True),
                    ('', False),
                    ('meh', True),
                    ('false', True),
                ):
                    os.environ['FOO'] = input_
                    c = Config(defaults={'foo': bool()})
                    c.load_shell_env()
                    eq_(c.foo, result)

Example 30

Project: invoke Source File: cli.py
    def _flag_value_task(self, value):
        r = self._parse("mytask -s {0} mytask2".format(value))
        eq_(len(r), 2)
        eq_(r[0].name, 'mytask')
        eq_(r[0].args.s.value, value)
        eq_(r[1].name, 'mytask2')

Example 31

Project: invoke Source File: config.py
            def numeric_types_become_casted(self):
                tests = [
                    (int, '5', 5),
                    (float, '5.5', 5.5),
                    # TODO: more?
                ]
                # Can't use '5L' in Python 3, even having it in a branch makes
                # it upset.
                if not six.PY3:
                    tests.append((long, '5', long(5)))  # noqa
                for old, new_, result in tests:
                    os.environ['FOO'] = new_
                    c = Config(defaults={'foo': old()})
                    c.load_shell_env()
                    eq_(c.foo, result)

Example 32

Project: invoke Source File: collection.py
        def positional_arglist_preserves_order_given(self):
            @task(positional=('second', 'first'))
            def mytask(ctx, first, second, third):
                pass
            c = Collection()
            c.add_task(mytask)
            ctx = c.to_contexts()[0]
            eq_(ctx.positional_args, [ctx.args['second'], ctx.args['first']])

Example 33

Project: invoke Source File: config.py
        def project_overrides_user(self):
            c = Config(
                user_prefix=join(CONFIGS_PATH, 'json', 'invoke'),
                project_home=join(CONFIGS_PATH, 'yaml'),
            )
            eq_(c.hooray, 'yaml')

Example 34

Project: invoke Source File: main.py
    def pty_puts_both_streams_in_stdout(self):
        if WINDOWS:
            return
        os.chdir('_support')
        err_echo = "{0} err.py".format(sys.executable)
        command = "echo foo && {0} bar".format(err_echo)
        r = run(command, hide='both', pty=True)
        eq_(r.stdout, 'foo\r\nbar\r\n')
        eq_(r.stderr, '')

Example 35

Project: invoke Source File: config.py
        def project_overrides_collection(self):
            c = Config(
                project_home=join(CONFIGS_PATH, 'yaml'),
            )
            c.load_collection({'hooray': 'defaults'})
            eq_(c.hooray, 'yaml')

Example 36

Project: invoke Source File: collection.py
        def access_merges_from_subcollections(self):
            inner = Collection('inner', self.task)
            inner.configure({'foo': 'bar'})
            self.root.configure({'biz': 'baz'})
            # With no inner collection
            eq_(set(self.root.configuration().keys()), set(['biz']))
            # With inner collection
            self.root.add_collection(inner)
            eq_(
                set(self.root.configuration('inner.task').keys()),
                set(['foo', 'biz'])
            )

Example 37

Project: invoke Source File: config.py
        def env_vars_override_user(self):
            os.environ['HOORAY'] = 'env'
            c = Config(
                user_prefix=join(CONFIGS_PATH, 'yaml', 'invoke'),
            )
            c.load_shell_env()
            eq_(c.hooray, 'env')

Example 38

Project: invoke Source File: cli.py
    def tasks_with_duplicately_named_kwargs(self):
        "mytask --mystring foo mytask3 --mystring bar"
        r = self._parse("mytask --mystring foo mytask3 --mystring bar")
        eq_(r[0].name, 'mytask')
        eq_(r[0].args.mystring.value, 'foo')
        eq_(r[1].name, 'mytask3')
        eq_(r[1].args.mystring.value, 'bar')

Example 39

Project: invoke Source File: config.py
        def env_vars_override_collection(self):
            os.environ['HOORAY'] = 'env'
            c = Config()
            c.load_collection({'hooray': 'defaults'})
            c.load_shell_env()
            eq_(c.hooray, 'env')

Example 40

Project: invoke Source File: collection.py
        def sibling_subcollections_ignored(self):
            inner = Collection('inner', self.task)
            inner.configure({'foo': 'hi there'})
            inner2 = Collection('inner2', Task(_func, name='task2'))
            inner2.configure({'foo': 'nope'})
            root = Collection(inner, inner2)
            eq_(root.configuration('inner.task')['foo'], 'hi there')
            eq_(root.configuration('inner2.task2')['foo'], 'nope')

Example 41

Project: invoke Source File: config.py
        def runtime_overrides_user(self):
            c = Config(
                runtime_path=join(CONFIGS_PATH, 'json', 'invoke.json'),
                user_prefix=join(CONFIGS_PATH, 'yaml', 'invoke'),
            )
            eq_(c.hooray, 'json')

Example 42

Project: invoke Source File: main.py
    @trap
    def bad_collection_exits_nonzero(self):
        result = run("inv -c nope -l", warn=True)
        eq_(result.exited, 1)
        assert not result.stdout
        assert result.stderr

Example 43

Project: invoke Source File: config.py
        def cli_overrides_override_all(self):
            "CLI-driven overrides win vs all other layers"
            # TODO: expand into more explicit tests like the above? meh
            c = Config(
                overrides={'hooray': 'overrides'},
                runtime_path=join(CONFIGS_PATH, 'json', 'invoke.json')
            )
            eq_(c.hooray, 'overrides')

Example 44

Project: invoke Source File: collection.py
        def keys_dont_have_to_exist_in_full_path(self):
            # Kinda duplicates earlier stuff; meh
            # Key only stored on leaf
            leaf = Collection('leaf', self.task)
            leaf.configure({'key': 'leaf-value'})
            middle = Collection('middle', leaf)
            root = Collection('root', middle)
            eq_(root.configuration('middle.leaf.task'), {'key': 'leaf-value'})
            # Key stored on mid + leaf but not root
            middle.configure({'key': 'whoa'})
            eq_(root.configuration('middle.leaf.task'), {'key': 'whoa'})

Example 45

Project: invoke Source File: collection.py
        def kwargs_act_as_name_args_for_given_objects(self):
            sub = Collection()
            @task
            def task1(ctx):
                pass
            ns = Collection(loltask=task1, notsub=sub)
            eq_(ns['loltask'], task1)
            eq_(ns.collections['notsub'], sub)

Example 46

Project: invoke Source File: context.py
Function: base_case
        def base_case(self):
            # NOTE: Assumes a user whose password is 'mypass' has been created
            # & added to passworded (not passwordless) sudo configuration; and
            # that this user is the one running the test suite. Only for
            # running on Travis, basically.
            if not os.environ.get('TRAVIS', False):
                skip()
            config = Config(overrides={'sudo': {'password': 'mypass'}})
            result = Context(config=config).sudo('whoami', hide=True)
            eq_(result.stdout.strip(), 'root')

Example 47

Project: invoke Source File: main.py
    def complex_nesting_under_ptys_doesnt_break(self):
        if WINDOWS: # Not sure how to make this work on Windows
            return
        # GH issue 191
        substr = "      hello\t\t\nworld with spaces"
        cmd = """ eval 'echo "{0}" ' """.format(substr)
        expected = '      hello\t\t\r\nworld with spaces\r\n'
        eq_(run(cmd, pty=True, hide='both').stdout, expected)

Example 48

Project: invoke Source File: runners.py
        def _hang_on_full_pipe(self, pty):
            class Whoops(Exception):
                pass
            runner = Local(Context())
            # Force runner IO thread-body method to raise an exception to mimic
            # real world encoding explosions/etc. When bug is present, this
            # will make the test hang until forcibly terminated.
            runner.handle_stdout = Mock(side_effect=Whoops, __name__='sigh')
            # NOTE: both Darwin (10.10) and Linux (Travis' docker image) have
            # this file. It's plenty large enough to fill most pipe buffers,
            # which is the triggering behavior.
            try:
                runner.run("cat /usr/share/dict/words", pty=pty)
            except ThreadException as e:
                eq_(len(e.exceptions), 1)
                ok_(e.exceptions[0].type is Whoops)
            else:
                assert False, "Did not receive expected ThreadException!"

Example 49

Project: invoke Source File: collection.py
            def inline_configuration(self):
                # No configuration given, none gotten
                eq_(self.fm(self.mod).configuration(), {})
                # Config kwarg given is reflected when config obtained
                eq_(
                    self.fm(self.mod, config={'foo': 'bar'}).configuration(),
                    {'foo': 'bar'}
                )

Example 50

Project: invoke Source File: config.py
        def python_modules_dont_load_special_vars(self):
            "Python modules don't load special vars"
            # Borrow another test's Python module.
            c = _load('system_prefix', 'python')
            # Sanity test that lowercase works
            eq_(c.hooray, 'python')
            # Real test that builtins, etc are stripped out
            for special in ('builtins', 'file', 'package', 'name', 'doc'):
                ok_('__{0}__'.format(special) not in c)
See More Examples - Go to Next Page
Page 1 Selected Page 2 Page 3 Page 4