Exemple #1
0
    def test_single_failing_test(self):
        with keep_score() as current_score:
            @test()
            def _():
                fail()

            self.assertEqual(current_score(), Score(0, 1))
Exemple #2
0
    def test_single_skipped_test(self):
        with keep_score() as current_score, skip_if(True):
            @test()
            def _():
                pass

            self.assertEqual(current_score(), Score(0, 1))
Exemple #3
0
    def test_single_passing_test(self):
        with keep_score() as current_score:
            @test()
            def _():
                pass

            self.assertEqual(current_score(), Score(1, 1))
Exemple #4
0
    def test_fail_fail(self):
        with keep_score() as current_score:
            @test()
            def _():
                fail()

            @test()
            def _():
                fail()

            self.assertEqual(current_score(), Score(0, 2))
Exemple #5
0
    def test_pass_pass(self):
        with keep_score() as current_score:
            @test()
            def _():
                pass

            @test()
            def _():
                pass

            self.assertEqual(current_score(), Score(2, 2))
Exemple #6
0
    def test_all_or_nothing_pf(self):
        with keep_score() as current_score:
            with all_or_nothing():
                @test()
                def _():
                    pass

                @test()
                def _():
                    fail()

            self.assertEqual(current_score(), Score(0, 2))
    def test_passing(self):
        def refimpl(x):
            return x

        def testimpl(x):
            return x

        with keep_score() as current_score, reference_based_test(
                refimpl, testimpl) as testcase:
            testcase(0)
            testcase(1)
            testcase(2)
            testcase(3)

            self.assertEqual(current_score(), Score(4, 4))
    def test_failing_parameter_modification(self):
        def refimpl(xs):
            return xs.append(1)

        def testimpl(xs):
            return xs.append(2)

        with keep_score() as current_score, reference_based_test(
                refimpl, testimpl) as testcase:
            testcase([])
            testcase([1])
            testcase([2])
            testcase([1, 2, 3])

            self.assertEqual(current_score(), Score(0, 4))
Exemple #9
0
    def test_cumulative_in_all_or_nothing(self):
        with keep_score() as current_score:
            with all_or_nothing():
                with cumulative():
                    @test()
                    def _():
                        pass

                    @test()
                    def _():
                        fail()

                with cumulative():
                    @test()
                    def _():
                        pass

                    @test()
                    def _():
                        fail()

            self.assertEqual(current_score(), Score(0, 4))
    def test_failing(self):
        expected = '''
        def foo(x):
            return x * 2
        '''

        actual = '''
        def foo(x):
            return x
        '''

        expected = load_code_from_string_into_module(dedent(expected),
                                                     'expected')
        actual = load_code_from_string_into_module(dedent(actual), 'actual')

        with reference_module(expected), tested_module(actual), keep_score(
        ) as current_score, reference_based_test('foo') as testcase:
            testcase(0)
            testcase(1)
            testcase(2)
            testcase(3)

            self.assertEqual(current_score(), Score(1, 4))