<commit_before>from test_provider_gtfs import provider

from busbus.entity import BaseEntityJSONEncoder

import json
import pytest


@pytest.fixture(scope='module')
def agency(provider):
    return next(provider.agencies)


def test_entity_repr(agency):
    assert 'DTA' in repr(agency)


def test_entity_failed_getattr(agency):
    with pytest.raises(AttributeError):
        agency.the_weather_in_london


def test_entity_failed_getitem(agency):
    with pytest.raises(KeyError):
        agency['the_weather_in_london']


def test_entity_to_dict(agency):
    assert dict(agency)['id'] == 'DTA'


def test_entity_to_json(provider):
    json_str = BaseEntityJSONEncoder().encode(next(provider.arrivals))
    json.loads(json_str)<commit_msg>Test the failure branch in BaseEntityJSONDecoder<commit_after>from test_provider_gtfs import provider

from busbus.entity import BaseEntityJSONEncoder

import json
import pytest


@pytest.fixture(scope='module')
def agency(provider):
    return next(provider.agencies)


def test_entity_repr(agency):
    assert 'DTA' in repr(agency)


def test_entity_failed_getattr(agency):
    with pytest.raises(AttributeError):
        agency.the_weather_in_london


def test_entity_failed_getitem(agency):
    with pytest.raises(KeyError):
        agency['the_weather_in_london']


def test_entity_to_dict(agency):
    assert dict(agency)['id'] == 'DTA'


def test_entity_to_json(provider):
    json_str = BaseEntityJSONEncoder().encode(next(provider.arrivals))
    json.loads(json_str)


def test_bad_json():
    with pytest.raises(TypeError):
        BaseEntityJSONEncoder().encode(set())
{'fraction_non_alphanumeric': 0.09635577516985794, 'fraction_numerical': 0.0, 'mean_word_length': 5.506024096385542, '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': '5279599', 'n_tokens_mistral': 550, 'n_tokens_neox': 528, 'n_words': 95}