<commit_before>import os

from spec import Spec

from invoke import run


class Runner_(Spec):
    class responding:
        # TODO: update respond_*.py so they timeout instead of hanging forever
        # when not being responded to

        def setup(self):
            os.chdir(os.path.join(os.path.dirname(__file__), '_support'))

        def base_case(self):
            # Basic "doesn't explode" test: respond.py will exit nonzero unless
            # this works, causing a Failure.
            responses = {r"What's the password\?": "<PASSWORD>"}
            # Gotta give -u or Python will line-buffer its stdout, so we'll
            # never actually see the prompt.
            run("python -u respond_base.py", responses=responses, hide=True)

        def both_streams(self):
            responses = {
                "standard out": "with it\n",
                "standard error": "between chair and keyboard\n",
            }
            run("python -u respond_both.py", responses=responses, hide=True)<commit_msg>Skel test re: trying to prove the sleep() is in place in the stdin loop<commit_after>import os

from spec import Spec

from invoke import run


class Runner_(Spec):
    class responding:
        # TODO: update respond_*.py so they timeout instead of hanging forever
        # when not being responded to

        def setup(self):
            os.chdir(os.path.join(os.path.dirname(__file__), '_support'))

        def base_case(self):
            # Basic "doesn't explode" test: respond.py will exit nonzero unless
            # this works, causing a Failure.
            responses = {r"What's the password\?": "<PASSWORD>"}
            # Gotta give -u or Python will line-buffer its stdout, so we'll
            # never actually see the prompt.
            run("python -u respond_base.py", responses=responses, hide=True)

        def both_streams(self):
            responses = {
                "standard out": "with it\n",
                "standard error": "between chair and keyboard\n",
            }
            run("python -u respond_both.py", responses=responses, hide=True)

        def stdin_mirroring_isnt_cpu_heavy(self):
            "stdin mirroring isn't CPU-heavy"
            # Run something for a couple seconds (assuming 1s or sub-second
            # execution doesn't look reliable, I bet it doesn't)
            # Capture CPU usage in same way that carbon's self-reporting shit
            # does
            # Find good metric for it and assert it's below that
            # Verify by undoing the sleep
{'fraction_non_alphanumeric': 0.0890894819466248, 'fraction_numerical': 0.0003924646781789639, 'mean_word_length': 2.13530135301353, 'pattern_counts': {'":': 6, '<': 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': '5734349', 'n_tokens_mistral': 696, 'n_tokens_neox': 663, 'n_words': 251}