<commit_before>from pathed import *
import os
import shutil
import sys

class Shell(Pathed):
    """Base class for command line tests"""
    def execute(self,command,*p,**k):
        """Return the fd of a command; can get output (stdout/err) and exitcode"""
        # We might be passed a file descriptor for some reason; if so, just return it
        if type(command) is file:
            return command
        # Redirect stderr to stdout
        # This is a bit of a hack, but I've not found a better way
        fd=os.popen(command+' 2>&1',*p,**k)
        return fd
    def output_and_exitcode(self,*p,**k):
        fd=self.execute(*p,**k)
        output = fd.read().strip()
        exitcode = fd.close()
        if k.pop('emit',False):
            print output
        return (output,exitcode)
    def exitcode(self,*p,**k):
        """Execute a command and return its exit code
        ...without printing its output/errors
        """
        ret = self.output_and_exitcode(*p,**k)
        return ret[1]

    def assertFailure(self,*p,**k):
        output,exitcode = self.output_and_exitcode(*p,**k)
        assert (exitcode), output
    def assertSuccess(self,*p,**k):
        output,exitcode = self.output_and_exitcode(*p,**k)
        #self.assert_(not exitcode, output)
        assert (not exitcode), output
<commit_msg>applied patch for shell test by <NAME><commit_after>from pathed import *
import os
import shutil
import sys

class Shell(Pathed):
    """Base class for command line tests"""
    def execute(self,command,*p,**k):
        """Return the fd of a command; can get output (stdout/err) and exitcode"""
        # We might be passed a file descriptor for some reason; if so, just return it
        if type(command) is file:
            return command
        # Redirect stderr to stdout
        # This is a bit of a hack, but I've not found a better way
        py_path = os.environ.get('PYTHONPATH', '')
        py_path_list = py_path.split(':')
        py_path_list.append(os.path.abspath('.'))
        os.environ['PYTHONPATH'] = ':'.join(py_path_list)
        fd=os.popen(command+' 2>&1',*p,**k)
        if py_path:
            py_path = os.environ['PYTHONPATH'] = py_path
        else:
            del os.environ['PYTHONPATH']
        return fd
    def output_and_exitcode(self,*p,**k):
        fd=self.execute(*p,**k)
        output = fd.read().strip()
        exitcode = fd.close()
        if k.pop('emit',False):
            print output
        return (output,exitcode)
    def exitcode(self,*p,**k):
        """Execute a command and return its exit code
        ...without printing its output/errors
        """
        ret = self.output_and_exitcode(*p,**k)
        return ret[1]

    def assertFailure(self,*p,**k):
        output,exitcode = self.output_and_exitcode(*p,**k)
        assert (exitcode), output
    def assertSuccess(self,*p,**k):
        output,exitcode = self.output_and_exitcode(*p,**k)
        #self.assert_(not exitcode, output)
        assert (not exitcode), output

{'fraction_non_alphanumeric': 0.12823061630218688, 'fraction_numerical': 0.0019880715705765406, 'mean_word_length': 2.5145518044237485, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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': '4634400', 'n_tokens_mistral': 930, 'n_tokens_neox': 907, 'n_words': 267}