<commit_before>from changes.constants import Result
from changes.models.test import TestResult
from changes.testutils.cases import TestCase


class TestResultTestCase(TestCase):
    def test_simple(self):
        build = self.create_build(self.project)
        result = TestResult(
            build=build,
            suite_name='foobar',
            name='Test',
            package='tests.changes.handlers.test_xunit',
            result=Result.skipped,
            message='collection skipped',
            duration=156,
        )
        test = result.save()

        assert test.build == build
        assert test.project == self.project
        assert test.name == 'Test'
        assert test.package == 'tests.changes.handlers.test_xunit'
        assert test.result == Result.skipped
        assert test.message == 'collection skipped'
        assert test.duration == 156

        suite = test.suite

        assert suite.name == 'foobar'
        assert suite.build == build
        assert suite.project == self.project

        groups = sorted(test.groups, key=lambda x: x.name)

        assert len(groups) == 2
        assert groups[0].build == build
        assert groups[0].project == self.project
        assert groups[0].name == 'tests.changes.handlers.test_xunit'
        assert groups[0].duration == 156
        assert groups[0].num_tests == 1
        assert groups[0].num_failed == 0
        assert groups[0].result == Result.skipped

        assert groups[1].build == build
        assert groups[1].project == self.project
        assert groups[1].name == 'tests.changes.handlers.test_xunit.Test'
        assert groups[1].duration == 156
        assert groups[1].num_tests == 1
        assert groups[1].num_failed == 0
        assert groups[1].result == Result.skipped<commit_msg>Test behavior of num_failed<commit_after>from changes.constants import Result
from changes.models.test import TestResult
from changes.testutils.cases import TestCase


class TestResultTestCase(TestCase):
    def test_simple(self):
        build = self.create_build(self.project)
        result = TestResult(
            build=build,
            suite_name='foobar',
            name='Test',
            package='tests.changes.handlers.test_xunit',
            result=Result.failed,
            message='collection failed',
            duration=156,
        )
        test = result.save()

        assert test.build == build
        assert test.project == self.project
        assert test.name == 'Test'
        assert test.package == 'tests.changes.handlers.test_xunit'
        assert test.result == Result.failed
        assert test.message == 'collection failed'
        assert test.duration == 156

        suite = test.suite

        assert suite.name == 'foobar'
        assert suite.build == build
        assert suite.project == self.project

        groups = sorted(test.groups, key=lambda x: x.name)

        assert len(groups) == 2
        assert groups[0].build == build
        assert groups[0].project == self.project
        assert groups[0].name == 'tests.changes.handlers.test_xunit'
        assert groups[0].duration == 156
        assert groups[0].num_tests == 1
        assert groups[0].num_failed == 1
        assert groups[0].result == Result.failed

        assert groups[1].build == build
        assert groups[1].project == self.project
        assert groups[1].name == 'tests.changes.handlers.test_xunit.Test'
        assert groups[1].duration == 156
        assert groups[1].num_tests == 1
        assert groups[1].num_failed == 1
        assert groups[1].result == Result.failed
{'fraction_non_alphanumeric': 0.10827318156579678, 'fraction_numerical': 0.017212659633536923, 'mean_word_length': 2.3055045871559634, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '107349', 'n_tokens_mistral': 994, 'n_tokens_neox': 943, 'n_words': 228}