<commit_before>from praw.models import (SubredditWidgets, SubredditWidgetsModeration,
                         Widget, WidgetModeration)

from ... import UnitTest


class TestWidgets(UnitTest):<commit_msg>Test WidgetEncoder to get coverage to 100%<commit_after>from json import dumps

from praw.models import (SubredditWidgets, SubredditWidgetsModeration,
                         Widget, WidgetModeration)
from praw.models.reddit.widgets import WidgetEncoder
from praw.models.base import PRAWBase

from ... import UnitTest


class TestWidgetEncoder(UnitTest):
    def test_bad_encode(self):
        data = [1, 'two', SubredditWidgetsModeration(
            self.reddit.subreddit('subreddit'), self.reddit)]
        try:
            dumps(data, cls=WidgetEncoder)  # should throw TypeError
        except TypeError:
            pass  # success
        else:
            assert False

    def test_good_encode(self):
        data = [1, 'two',
                PRAWBase(self.reddit, _data={'_secret': 'no', '3': 3})]
        assert '[1, "two", {"3": 3}]' == dumps(data, cls=WidgetEncoder)


class TestWidgets(UnitTest):
{'fraction_non_alphanumeric': 0.10125448028673835, 'fraction_numerical': 0.008960573476702509, 'mean_word_length': 2.8919860627177703, 'pattern_counts': {'":': 1, '<': 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': '4029339', 'n_tokens_mistral': 333, 'n_tokens_neox': 331, 'n_words': 81}