<commit_before>#! /usr/bin/env python
"""Basic tests for os.popen()

  Particularly useful for platforms that fake popen.
"""

import os
import sys
from test_support import TestSkipped
from os import popen

# Test that command-lines get down as we expect.
# To do this we execute:
#    python -c "import sys;print sys.argv" {rest_of_commandline}
# This results in Python being spawned and printing the sys.argv list.
# We can then eval() the result of this, and see what each argv was.
def _do_test_commandline(cmdline, expected):
    cmd = 'python -c "import sys;print sys.argv" %s' % (cmdline,)
    data = popen(cmd).read()
    got = eval(data)[1:] # strip off argv[0]
    if got != expected:
        print "Error in popen commandline handling."
        print " executed '%s', expected '%r', but got '%r'" \
                                                    % (cmdline, expected, got)
<commit_msg>Get popen test to work even if python is not in the path<commit_after>#! /usr/bin/env python
"""Basic tests for os.popen()

  Particularly useful for platforms that fake popen.
"""

import os
import sys
from test_support import TestSkipped
from os import popen

# Test that command-lines get down as we expect.
# To do this we execute:
#    python -c "import sys;print sys.argv" {rest_of_commandline}
# This results in Python being spawned and printing the sys.argv list.
# We can then eval() the result of this, and see what each argv was.
def _do_test_commandline(cmdline, expected):
    cmd = '%s -c "import sys;print sys.argv" %s' % (sys.executable, cmdline)
    data = popen(cmd).read()
    got = eval(data)[1:] # strip off argv[0]
    if got != expected:
        print "Error in popen commandline handling."
        print " executed '%s', expected '%r', but got '%r'" \
                                                    % (cmdline, expected, got)

{'fraction_non_alphanumeric': 0.10452586206896551, 'fraction_numerical': 0.0021551724137931034, 'mean_word_length': 2.8768267223382047, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '77990', 'n_tokens_mistral': 546, 'n_tokens_neox': 540, 'n_words': 229}