<commit_before>import os
import unittest
import subprocess
import utils
TOPDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
test_dir = utils.set_search_paths(TOPDIR)
utils.set_search_paths(TOPDIR)

from allosmod.util import check_output

class Tests(unittest.TestCase):
    def test_bad(self):
        """Test wrong arguments to get_rest"""
        for args in ([], [''] * 2):
            out = check_output(['allosmod', 'get_rest'] + args,
                               stderr=subprocess.STDOUT, retcode=2)
            out = check_output(['python', '-m',
                                'allosmod.get_rest'] + args,
                               stderr=subprocess.STDOUT, retcode=2)

    def test_simple(self):
        """Simple complete run of get_rest"""
        with open('get_rest.in', 'w') as fh:
            pass
        out = check_output(['allosmod', 'get_rest',
                           os.path.join(test_dir, 'input',
                                        'asite_pdb1.pdb')])
        os.unlink('get_rest.in')
        # PDB file contains no sugars, so no restraints should be output
        self.assertEqual(out, '')


if __name__ == '__main__':
    unittest.main()<commit_msg>Make sure that output is text in Python 2 & 3.<commit_after>import os
import unittest
import subprocess
import utils
TOPDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
test_dir = utils.set_search_paths(TOPDIR)
utils.set_search_paths(TOPDIR)

from allosmod.util import check_output

class Tests(unittest.TestCase):
    def test_bad(self):
        """Test wrong arguments to get_rest"""
        for args in ([], [''] * 2):
            out = check_output(['allosmod', 'get_rest'] + args,
                               stderr=subprocess.STDOUT, retcode=2)
            out = check_output(['python', '-m',
                                'allosmod.get_rest'] + args,
                               stderr=subprocess.STDOUT, retcode=2)

    def test_simple(self):
        """Simple complete run of get_rest"""
        with open('get_rest.in', 'w') as fh:
            pass
        out = check_output(['allosmod', 'get_rest',
                           os.path.join(test_dir, 'input',
                                        'asite_pdb1.pdb')],
                           universal_newlines=True)
        os.unlink('get_rest.in')
        # PDB file contains no sugars, so no restraints should be output
        self.assertEqual(out, '')


if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.12266029470330546, 'fraction_numerical': 0.00398247710075667, 'mean_word_length': 2.033816425120773, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '474857', 'n_tokens_mistral': 757, 'n_tokens_neox': 738, 'n_words': 167}