Beispiel #1
0
    def test_run_runs_named_scenarios(self):
        scenarios = [Mock(Scenario), Mock(Scenario)]
        scenarios[0].name = "first scenario"
        scenarios[1].name = "second scenario"
        scenarios[0].tags = []
        scenarios[1].tags = []
        # -- FAKE-CHECK:
        scenarios[0].should_run_with_name_select.return_value = True
        scenarios[1].should_run_with_name_select.return_value = False

        for scenario in scenarios:
            scenario.run.return_value = False

        self.config.tag_expression.check.return_value = True  # pylint: disable=no-member
        self.config.name = ["first", "third"]
        self.config.name_re = Configuration.build_name_re(self.config.name)

        feature = Feature("foo.feature",
                          1,
                          u"Feature",
                          u"foo",
                          scenarios=scenarios)

        feature.run(self.runner)

        scenarios[0].run.assert_called_with(self.runner)
        assert not scenarios[1].run.called
        scenarios[0].should_run_with_name_select.assert_called_with(
            self.config)
        scenarios[1].should_run_with_name_select.assert_called_with(
            self.config)
Beispiel #2
0
    def test_formatter_background_not_called_when_feature_has_no_background(
            self):
        feature = Feature('foo.feature', 1, u'Feature', u'foo')

        feature.run(self.runner)

        assert not self.formatters[0].background.called
Beispiel #3
0
    def test_run_exclude_named_scenarios_with_regexp(self):
        # -- NOTE: Works here only because it is run against Mocks.
        scenarios = [Mock(), Mock(), Mock()]
        scenarios[0].name = "Alice in Florida"
        scenarios[1].name = "Alice and Bob"
        scenarios[2].name = "Bob in Paris"
        scenarios[0].tags = []
        scenarios[1].tags = []
        scenarios[2].tags = []
        # -- FAKE-CHECK:
        scenarios[0].should_run_with_name_select.return_value = False
        scenarios[1].should_run_with_name_select.return_value = False
        scenarios[2].should_run_with_name_select.return_value = True

        for scenario in scenarios:
            scenario.run.return_value = False

        self.config.tags.check.return_value = True  # pylint: disable=no-member
        self.config.name = ["(?!Alice)"]    # Exclude all scenarios with "Alice"
        self.config.name_re = Configuration.build_name_re(self.config.name)

        feature = Feature('foo.feature', 1, u'Feature', u'foo',
                          scenarios=scenarios)

        feature.run(self.runner)

        assert not scenarios[0].run.called
        scenarios[0].should_run_with_name_select.assert_called_with(self.config)
        scenarios[1].should_run_with_name_select.assert_called_with(self.config)
        scenarios[2].should_run_with_name_select.assert_called_with(self.config)
        scenarios[0].run.assert_not_called()
        scenarios[1].run.assert_not_called()
        scenarios[2].run.assert_called_with(self.runner)
Beispiel #4
0
    def test_run_runs_named_scenarios(self):
        scenarios = [Mock(Scenario), Mock(Scenario)]
        scenarios[0].name = 'first scenario'
        scenarios[1].name = 'second scenario'
        scenarios[0].tags = []
        scenarios[1].tags = []
        # -- FAKE-CHECK:
        scenarios[0].should_run_with_name_select.return_value = True
        scenarios[1].should_run_with_name_select.return_value = False

        for scenario in scenarios:
            scenario.run.return_value = False

        self.config.tags.check.return_value = True  # pylint: disable=no-member
        self.config.name = ['first', 'third']
        self.config.name_re = Configuration.build_name_re(self.config.name)

        feature = Feature('foo.feature',
                          1,
                          u'Feature',
                          u'foo',
                          scenarios=scenarios)

        feature.run(self.runner)

        scenarios[0].run.assert_called_with(self.runner)
        assert not scenarios[1].run.called
        scenarios[0].should_run_with_name_select.assert_called_with(
            self.config)
        scenarios[1].should_run_with_name_select.assert_called_with(
            self.config)
Beispiel #5
0
    def test_run_runs_named_scenarios(self):
        scenarios = [Mock(Scenario), Mock(Scenario)]
        scenarios[0].name = "first scenario"
        scenarios[1].name = "second scenario"
        scenarios[0].tags = []
        scenarios[1].tags = []
        # -- FAKE-CHECK:
        scenarios[0].should_run_with_name_select.return_value = True
        scenarios[1].should_run_with_name_select.return_value = False

        for scenario in scenarios:
            scenario.run.return_value = False

        self.config.tag_expression.check.return_value = True  # pylint: disable=no-member
        self.config.name = ["first", "third"]
        self.config.name_re = Configuration.build_name_re(self.config.name)

        feature = Feature("foo.feature", 1, u"Feature", u"foo",
                          scenarios=scenarios)

        feature.run(self.runner)

        scenarios[0].run.assert_called_with(self.runner)
        assert not scenarios[1].run.called
        scenarios[0].should_run_with_name_select.assert_called_with(self.config)
        scenarios[1].should_run_with_name_select.assert_called_with(self.config)
Beispiel #6
0
    def test_formatter_background_called_when_feature_has_background(self):
        feature = Feature('foo.feature', 1, u'Feature', u'foo',
                          background=Mock())

        feature.run(self.runner)

        self.formatters[0].background.assert_called_with(feature.background)
Beispiel #7
0
    def test_formatter_feature_called(self):
        feature = Feature("foo.feature", 1, u"Feature", u"foo",
                          background=Mock())

        feature.run(self.runner)

        self.formatters[0].feature.assert_called_with(feature)
Beispiel #8
0
    def test_run_runs_named_scenarios(self):
        scenarios = [Mock(Scenario), Mock(Scenario)]
        scenarios[0].name = 'first scenario'
        scenarios[1].name = 'second scenario'
        scenarios[0].tags = []
        scenarios[1].tags = []
        # -- FAKE-CHECK:
        scenarios[0].should_run_with_name_select.return_value = True
        scenarios[1].should_run_with_name_select.return_value = False

        for scenario in scenarios:
            scenario.run.return_value = False

        self.config.tags.check.return_value = True  # pylint: disable=no-member
        self.config.name = ['first', 'third']
        self.config.name_re = Configuration.build_name_re(self.config.name)

        feature = Feature('foo.feature', 1, u'Feature', u'foo',
                          scenarios=scenarios)

        feature.run(self.runner)

        scenarios[0].run.assert_called_with(self.runner)
        assert not scenarios[1].run.called
        scenarios[0].should_run_with_name_select.assert_called_with(self.config)
        scenarios[1].should_run_with_name_select.assert_called_with(self.config)
Beispiel #9
0
    def test_formatter_feature_called(self):
        feature = Feature("foo.feature",
                          1,
                          u"Feature",
                          u"foo",
                          background=Mock())

        feature.run(self.runner)

        self.formatters[0].feature.assert_called_with(feature)
Beispiel #10
0
    def test_formatter_background_called_when_feature_has_background(self):
        feature = Feature('foo.feature',
                          1,
                          u'Feature',
                          u'foo',
                          background=Mock())

        feature.run(self.runner)

        self.formatters[0].background.assert_called_with(feature.background)
Beispiel #11
0
    def test_run_runs_scenarios(self):
        scenarios = [Mock(), Mock()]
        for scenario in scenarios:
            scenario.tags = []
            scenario.run.return_value = False

        self.config.tag_expression.check.return_value = True  # pylint: disable=no-member
        self.config.name = []

        feature = Feature("foo.feature", 1, u"Feature", u"foo",
                          scenarios=scenarios)

        feature.run(self.runner)

        for scenario in scenarios:
            scenario.run.assert_called_once_with(self.runner)
Beispiel #12
0
    def test_run_runs_scenarios(self):
        scenarios = [Mock(), Mock()]
        for scenario in scenarios:
            scenario.tags = []
            scenario.run.return_value = False

        self.config.tags.check.return_value = True  # pylint: disable=no-member
        self.config.name = []

        feature = Feature('foo.feature', 1, u'Feature', u'foo',
                          scenarios=scenarios)

        feature.run(self.runner)

        for scenario in scenarios:
            scenario.run.assert_called_with(self.runner)
Beispiel #13
0
    def test_run_runs_scenarios(self):
        scenarios = [Mock(), Mock()]
        for scenario in scenarios:
            scenario.tags = []
            scenario.run.return_value = False

        self.config.tag_expression.check.return_value = True  # pylint: disable=no-member
        self.config.name = []

        feature = Feature("foo.feature",
                          1,
                          u"Feature",
                          u"foo",
                          scenarios=scenarios)

        feature.run(self.runner)

        for scenario in scenarios:
            scenario.run.assert_called_once_with(self.runner)
Beispiel #14
0
    def test_run_runs_scenarios(self):
        scenarios = [Mock(), Mock()]
        for scenario in scenarios:
            scenario.tags = []
            scenario.run.return_value = False

        self.config.tags.check.return_value = True  # pylint: disable=no-member
        self.config.name = []

        feature = Feature('foo.feature',
                          1,
                          u'Feature',
                          u'foo',
                          scenarios=scenarios)

        feature.run(self.runner)

        for scenario in scenarios:
            scenario.run.assert_called_with(self.runner)
Beispiel #15
0
    def test_run_exclude_named_scenarios_with_regexp(self):
        # -- NOTE: Works here only because it is run against Mocks.
        scenarios = [Mock(), Mock(), Mock()]
        scenarios[0].name = "Alice in Florida"
        scenarios[1].name = "Alice and Bob"
        scenarios[2].name = "Bob in Paris"
        scenarios[0].tags = []
        scenarios[1].tags = []
        scenarios[2].tags = []
        # -- FAKE-CHECK:
        scenarios[0].should_run_with_name_select.return_value = False
        scenarios[1].should_run_with_name_select.return_value = False
        scenarios[2].should_run_with_name_select.return_value = True

        for scenario in scenarios:
            scenario.run.return_value = False

        self.config.tags.check.return_value = True  # pylint: disable=no-member
        self.config.name = ["(?!Alice)"]  # Exclude all scenarios with "Alice"
        self.config.name_re = Configuration.build_name_re(self.config.name)

        feature = Feature('foo.feature',
                          1,
                          u'Feature',
                          u'foo',
                          scenarios=scenarios)

        feature.run(self.runner)

        assert not scenarios[0].run.called
        scenarios[0].should_run_with_name_select.assert_called_with(
            self.config)
        scenarios[1].should_run_with_name_select.assert_called_with(
            self.config)
        scenarios[2].should_run_with_name_select.assert_called_with(
            self.config)
        scenarios[0].run.assert_not_called()
        scenarios[1].run.assert_not_called()
        scenarios[2].run.assert_called_with(self.runner)
Beispiel #16
0
    def test_feature_hooks_not_run_if_feature_not_being_run(self):
        self.config.tag_expression.check.return_value = False  # pylint: disable=no-member

        feature = Feature("foo.feature", 1, u"Feature", u"foo")
        feature.run(self.runner)
        assert not self.run_hook.called
Beispiel #17
0
    def test_formatter_background_not_called_when_feature_has_no_background(self):
        feature = Feature('foo.feature', 1, u'Feature', u'foo')

        feature.run(self.runner)

        assert not self.formatters[0].background.called
Beispiel #18
0
    def test_feature_hooks_not_run_if_feature_not_being_run(self):
        self.config.tags.check.return_value = False  # pylint: disable=no-member

        feature = Feature('foo.feature', 1, u'Feature', u'foo')
        feature.run(self.runner)
        assert not self.run_hook.called
Beispiel #19
0
    def test_feature_hooks_not_run_if_feature_not_being_run(self):
        self.config.tag_expression.check.return_value = False  # pylint: disable=no-member

        feature = Feature("foo.feature", 1, u"Feature", u"foo")
        feature.run(self.runner)
        assert not self.run_hook.called
Beispiel #20
0
    def test_feature_hooks_not_run_if_feature_not_being_run(self):
        self.config.tags.check.return_value = False  # pylint: disable=no-member

        feature = Feature('foo.feature', 1, u'Feature', u'foo')
        feature.run(self.runner)
        assert not self.run_hook.called