<commit_before>from serfclient import result


class TestSerfResult(object):
    def test_initialises_to_none(self):
        r = result.SerfResult()
        assert r.head is None
        assert r.body is None

    def test_provides_a_pretty_printed_form_for_repl_use(self):
        r = result.SerfResult(head={"a": 1}, body=('foo', 'bar'))
        assert str(r) == \
            "SerfResult<head={'a': 1},body=('foo', 'bar')>"

    def test_can_convert_to_list(self):
        r = result.SerfResult(head=1, body=2)
        assert sorted(list(r)) == [1, 2]

    def test_can_convert_to_tuple(self):
        r = result.SerfResult(head=1, body=2)
        assert sorted(tuple(r)) == [1, 2]<commit_msg>Reuse tests for converting to common data structures<commit_after>import pytest

from serfclient import result


class TestSerfResult(object):
    @pytest.fixture
    def head_and_body_result(self):
        return result.SerfResult(head=1, body=2)

    def test_initialises_to_none(self):
        r = result.SerfResult()
        assert r.head is None
        assert r.body is None

    def test_provides_a_pretty_printed_form_for_repl_use(self):
        r = result.SerfResult(head={"a": 1}, body=('foo', 'bar'))
        assert str(r) == \
            "SerfResult<head={'a': 1},body=('foo', 'bar')>"

    def test_can_convert_to_list_and_tuple(self, head_and_body_result):
        for structure in [list, tuple]:
            assert sorted(structure(head_and_body_result)) == [1, 2]
{'fraction_non_alphanumeric': 0.12737127371273713, 'fraction_numerical': 0.01084010840108401, 'mean_word_length': 3.318713450292398, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '5769045', 'n_tokens_mistral': 515, 'n_tokens_neox': 498, 'n_words': 104}