<commit_before>from unittest import TestCase
import os

from twisted.trial.reporter import TreeReporter

from virtue import _cli


class TestParser(TestCase):
    def parse_args(self, argv):
        return _cli.main.make_context("virtue", argv).params

    def test_it_parses_out_tests(self):
        arguments = self.parse_args(["foo", "bar", "baz"])
        self.assertEqual(list(arguments["tests"]), ["foo", "bar", "baz"])

    def test_it_retrieves_built_in_reporters_by_name(self):
        arguments = self.parse_args(["--reporter", "tree", "foo"])
        self.assertIsInstance(arguments["reporter"], TreeReporter)

    reporter = lambda: 12

    def test_it_retrieves_other_reporters_by_fully_qualified_name(self):
        arguments = self.parse_args(
            ["--reporter", "virtue.tests.test_cli.TestParser.reporter", "abc"],
        )
        self.assertEqual(arguments["reporter"], 12)

    def test_stop_after(self):
        arguments = self.parse_args(["-xxx", "bar", "baz"])
        self.assertEqual(
            (arguments["stop_after"], list(arguments["tests"])),
            (3, ["bar", "baz"]),
        )

    def test_stop_after_default(self):
        arguments = self.parse_args(["-x", "bar", "baz"])
        self.assertEqual(
            (arguments["stop_after"], list(arguments["tests"])),
            (1, ["bar", "baz"]),
        )


class TestMain(TestCase):
    # TODO: these write to stdout
    def test_it_exits_successfully_for_successful_runs(self):<commit_msg>Hooray static methods.<commit_after>from unittest import TestCase
import os

from twisted.trial.reporter import TreeReporter

from virtue import _cli


def DumbReporter():
    return 12


class TestParser(TestCase):
    def parse_args(self, argv):
        return _cli.main.make_context("virtue", argv).params

    def test_it_parses_out_tests(self):
        arguments = self.parse_args(["foo", "bar", "baz"])
        self.assertEqual(list(arguments["tests"]), ["foo", "bar", "baz"])

    def test_it_retrieves_built_in_reporters_by_name(self):
        arguments = self.parse_args(["--reporter", "tree", "foo"])
        self.assertIsInstance(arguments["reporter"], TreeReporter)

    def test_it_retrieves_other_reporters_by_fully_qualified_name(self):
        arguments = self.parse_args(
            ["--reporter", "virtue.tests.test_cli.DumbReporter", "abc"],
        )
        self.assertEqual(arguments["reporter"], DumbReporter())

    def test_stop_after(self):
        arguments = self.parse_args(["-xxx", "bar", "baz"])
        self.assertEqual(
            (arguments["stop_after"], list(arguments["tests"])),
            (3, ["bar", "baz"]),
        )

    def test_stop_after_default(self):
        arguments = self.parse_args(["-x", "bar", "baz"])
        self.assertEqual(
            (arguments["stop_after"], list(arguments["tests"])),
            (1, ["bar", "baz"]),
        )


class TestMain(TestCase):
    # TODO: these write to stdout
    def test_it_exits_successfully_for_successful_runs(self):
{'fraction_non_alphanumeric': 0.14579873796081036, 'fraction_numerical': 0.0033211557622052474, 'mean_word_length': 3.4164222873900294, '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': '7453875', 'n_tokens_mistral': 966, 'n_tokens_neox': 920, 'n_words': 172}