Beispiel #1
0
    def test_positional_arguments(self):
        text = "has a {}, an {:d} and a {:f}"
        matcher = matchers.ParseMatcher(self.record_args, text)
        context = runner.Context(Mock())

        m = matcher.match("has a foo, an 11 and a 3.14159")
        m.run(context)
        eq_(self.recorded_args, ((context, 'foo', 11, 3.14159), {}))
Beispiel #2
0
    def test_run_hook_does_not_runs_a_hook_that_exists_if_dry_run(self):
        r = runner.Runner(None)
        r.config = Mock()
        r.config.dry_run = True
        r.hooks["before_lunch"] = hook = Mock()
        args = (runner.Context(Mock()), Mock(), Mock())
        r.run_hook("before_lunch", *args)

        assert len(hook.call_args_list) == 0
Beispiel #3
0
    def test_run_hook_runs_a_hook_that_exists(self):
        r = runner.Runner(None)
        r.config = Mock()
        r.config.dry_run = False
        r.hooks['before_lunch'] = hook = Mock()
        args = (runner.Context(Mock()), Mock(), Mock())
        r.run_hook('before_lunch', *args)

        hook.assert_called_with(*args)
Beispiel #4
0
    def test_run_hook_runs_a_hook_that_exists(self):
        config = Mock()
        r = runner.Runner(config)
        # XXX r.config = Mock()
        r.config.stdout_capture = False
        r.config.stderr_capture = False
        r.config.dry_run = False
        r.hooks["before_lunch"] = hook = Mock()
        args = (runner.Context(Mock()), Mock(), Mock())
        r.run_hook("before_lunch", *args)

        hook.assert_called_with(*args)
Beispiel #5
0
    def test_named_arguments(self):
        text = "has a {string}, an {integer:d} and a {decimal:f}"
        matcher = matchers.ParseMatcher(self.record_args, text)
        context = runner.Context(Mock())

        m = matcher.match("has a foo, an 11 and a 3.14159")
        m.run(context)
        eq_(self.recorded_args, ((context,), {
            'string': 'foo',
            'integer': 11,
            'decimal': 3.14159
        }))
Beispiel #6
0
 def setUp(self):
     runner_ = Mock()
     self.config = runner_.config = Mock()
     runner_.config.verbose = False
     runner_.config.stdout_capture = False
     runner_.config.stderr_capture = False
     runner_.config.log_capture = False
     self.context = runner.Context(runner_)
     runner_.context = self.context
     self.context.feature = Mock()
     self.context.feature.parser = parser.Parser()
     if not self.step_registry:
         # -- SETUP ONCE:
         self.step_registry = step_registry.StepRegistry()
         ExampleSteps.register_steps_with(self.step_registry)
     ExampleSteps.text = None
     ExampleSteps.table = None
Beispiel #7
0
 def setUp(self):
     r = Mock()
     self.config = r.config = Mock()
     r.config.verbose = False
     self.context = runner.Context(r)