<commit_before>import os, sys
try:
    import sybprocess
except ImportError:
    # user private copy for old Python versions
    import MonetDBtesting.subprocess26 as subprocess

def client(cmd, input = None):
    clt = subprocess.Popen(cmd,
                           shell = True,
                           stdin = subprocess.PIPE,
                           stdout = subprocess.PIPE,
                           stderr = subprocess.PIPE,
                           universal_newlines = True)
    out, err = clt.communicate(input)
    sys.stdout.write(out)
    sys.stderr.write(err)

def main():
    xq_client = os.getenv('XQUERY_CLIENT')
    client('%s --input=my-document --collection=my-collection' % xq_client,
           '<document>test document</document>')
    client('%s -s "pf:documents()"' % xq_client)
    client('%s -s "pf:del-doc(\'my-document\')"' % xq_client)

main()<commit_msg>Make test independent of whatever else is in the database. Also, use a different way of calling subprocess.Popen so that we can use quotes and dollars without having to do difficult cross-architectural escaping.<commit_after>import os, sys
try:
    import sybprocess
except ImportError:
    # user private copy for old Python versions
    import MonetDBtesting.subprocess26 as subprocess

def client(cmd, input = None):
    clt = subprocess.Popen(cmd,
                           stdin = subprocess.PIPE,
                           stdout = subprocess.PIPE,
                           stderr = subprocess.PIPE,
                           universal_newlines = True)
    out, err = clt.communicate(input)
    sys.stdout.write(out)
    sys.stderr.write(err)

def main():
    xq_client = os.getenv('XQUERY_CLIENT').split()
    client(xq_client + ['--input=my-document', '--collection=my-collection'],
           '<document>test document</document>')
    client(xq_client + ['-s', 'for $doc in pf:documents() where $doc/@url = "my-document" return $doc'])
    client(xq_client + ['-s', 'pf:del-doc("my-document")'])

main()
{'fraction_non_alphanumeric': 0.11574764033780427, 'fraction_numerical': 0.001987083954297069, 'mean_word_length': 2.4135593220338984, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6079963', 'n_tokens_mistral': 605, 'n_tokens_neox': 596, 'n_words': 152}