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

from allosmod.util import check_output

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

    def test_simple(self):
        """Simple complete run of spline"""
        with open('test.pdb', 'w') as fh:
            fh.write("""
ATOM      2  CA  ALA A   1      27.449  14.935   5.140  1.00 29.87           C
ATOM      7  CA  VAL A   2      26.593  16.867   8.258  1.00120.51           C
""")
        check_output(['allosmod', 'spline', 'test.pdb',
                      os.path.join(test_dir, 'input', 'edited.rsr'), 'out.rsr'])
        rsr = open('out.rsr').read()
        expected = open(os.path.join(test_dir, 'input', 'converted.rsr')).read()
        self.assertEqual(rsr, expected)
        for f in ('test.pdb', 'out.rsr'):
            os.unlink(f)

if __name__ == '__main__':
    unittest.main()<commit_msg>Make sure files are closed when we're done<commit_after>import unittest
import subprocess
import os
import sys
import utils
TOPDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
test_dir = utils.set_search_paths(TOPDIR)

from allosmod.util import check_output

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

    def test_simple(self):
        """Simple complete run of spline"""
        with open('test.pdb', 'w') as fh:
            fh.write("""
ATOM      2  CA  ALA A   1      27.449  14.935   5.140  1.00 29.87           C
ATOM      7  CA  VAL A   2      26.593  16.867   8.258  1.00120.51           C
""")
        check_output(['allosmod', 'spline', 'test.pdb',
                      os.path.join(test_dir, 'input', 'edited.rsr'), 'out.rsr'])
        with open('out.rsr') as fh:
            rsr = fh.read()
        with open(os.path.join(test_dir, 'input', 'converted.rsr')) as fh:
            expected = fh.read()
        self.assertEqual(rsr, expected)
        for f in ('test.pdb', 'out.rsr'):
            os.unlink(f)

if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.1421653407125562, 'fraction_numerical': 0.03459010722933241, 'mean_word_length': 1.9570552147239264, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5859042', 'n_tokens_mistral': 1018, 'n_tokens_neox': 957, 'n_words': 226}