<commit_before># Licensed under a 3-clause BSD style license - see LICENSE.rst

import json

# The MockResponse class is currently relied upon in code and thus
# temporarily got moved out of testing_tools to avoid adding pytest as a
# mandatory dependency


class MockResponse(object):
    """
    A mocked/non-remote version of `astroquery.query.AstroResponse`
    """

    def __init__(self, content=None, url=None, headers={},
                 content_type=None, stream=False, auth=None, status_code=200,
                 verify=True):
        assert content is None or hasattr(content, 'decode')
        self.content = content
        self.raw = content
        self.headers = headers
        if content_type is not None:
            self.headers.update({'Content-Type': content_type})
        self.url = url
        self.auth = auth
        self.status_code = status_code

    def iter_lines(self):
        c = self.content.split(b"\n")
        for l in c:
            yield l

    def raise_for_status(self):
        pass

    def json(self):
        try:
            return json.loads(self.content)
        except TypeError:
            return json.loads(self.content.decode('utf-8'))

    @property<commit_msg>testing (mock) fix<commit_after># Licensed under a 3-clause BSD style license - see LICENSE.rst

import json

# The MockResponse class is currently relied upon in code and thus
# temporarily got moved out of testing_tools to avoid adding pytest as a
# mandatory dependency


class MockResponse(object):
    """
    A mocked/non-remote version of `astroquery.query.AstroResponse`
    """

    def __init__(self, content=None, url=None, headers={}, content_type=None,
                 stream=False, auth=None, status_code=200, verify=True,
                 allow_redirects=True):
        assert content is None or hasattr(content, 'decode')
        self.content = content
        self.raw = content
        self.headers = headers
        if content_type is not None:
            self.headers.update({'Content-Type': content_type})
        self.url = url
        self.auth = auth
        self.status_code = status_code

    def iter_lines(self):
        c = self.content.split(b"\n")
        for l in c:
            yield l

    def raise_for_status(self):
        pass

    def json(self):
        try:
            return json.loads(self.content)
        except TypeError:
            return json.loads(self.content.decode('utf-8'))

    @property
{'fraction_non_alphanumeric': 0.09013398294762484, 'fraction_numerical': 0.004060089321965083, 'mean_word_length': 2.3387533875338753, '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': '5076993', 'n_tokens_mistral': 698, 'n_tokens_neox': 679, 'n_words': 208}