class TestRunner(object):

    def setup(self):
        self.runner = Runner(None, ())

    def test_result_depends_on_configuration_runs(self):
        failing = Mock()
        failing.can_fail = False
        failing.run_build.side_effect = Exception()

        succeeding = Mock()
        succeeding.can_fail = False

        failing_and_can_fail = Mock()
        failing_and_can_fail.can_fail = True
        failing_and_can_fail.run_build.side_effect = Exception()

        for confs, result in (
            ((failing,), 1),
            ((succeeding,), 0),
            ((failing_and_can_fail,), 0),
            ((failing, succeeding), 1),
            ((failing, failing_and_can_fail), 1),
            ((succeeding, failing_and_can_fail), 0),
                ((succeeding, failing, failing_and_can_fail), 1)):
            for confs_permutation in permutations(confs):
                yield (self.check_configurations_and_result,
                       confs_permutation,
                       result)

    def check_configurations_and_result(self, configurations, result):
        self.runner.configurations = configurations
        eq_(self.runner.run(), result)
 def setup(self):
     self.runner = Runner(None, ())