<commit_before>import pytest

from share.models import Subject
from share.models.meta import ThroughSubjects
from share.disambiguation import disambiguate


def create_subject(name):
    Subject.objects.bulk_create([
        Subject(pk=1, name=name, lineages=[])
    ])
    return Subject.objects.get(name=name)


class TestSubject:

    @pytest.mark.django_db
    def test_disambiguates(self):
        oldSubject = create_subject('This')
        disSubject = disambiguate('_:', {'name': 'This'}, Subject)

        assert disSubject is not None
        assert disSubject.id == oldSubject.id
        assert disSubject.name == oldSubject.name

    @pytest.mark.django_db
    def test_does_not_disambiguate(self):
        oldSubject = create_subject('This')
        disSubject = None
        try:
            disSubject = disambiguate('_:', {'name': 'That'}, Subject)
        except:
            assert disSubject is None
            return
        assert False<commit_msg>Idiom.<commit_after>import pytest

from share.models import Subject
from share.models.meta import ThroughSubjects
from share.disambiguation import disambiguate


def create_subject(name):
    Subject.objects.bulk_create([
        Subject(pk=1, name=name, lineages=[])
    ])
    return Subject.objects.get(name=name)


class TestSubject:

    @pytest.mark.django_db
    def test_disambiguates(self):
        oldSubject = create_subject('This')
        disSubject = disambiguate('_:', {'name': 'This'}, Subject)

        assert disSubject is not None
        assert disSubject.id == oldSubject.id
        assert disSubject.name == oldSubject.name

    @pytest.mark.django_db
    def test_does_not_disambiguate(self):
        oldSubject = create_subject('This')
        disSubject = None
        try:
            disSubject = disambiguate('_:', {'name': 'That'}, Subject)
            assert False
        except:
            assert disSubject is None
{'fraction_non_alphanumeric': 0.09854014598540146, 'fraction_numerical': 0.0010427528675703858, 'mean_word_length': 2.9083503054989817, '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': '663057', 'n_tokens_mistral': 547, 'n_tokens_neox': 532, 'n_words': 130}