<commit_before>#!/usr/bin/env python
"""
Python test script
"""
__author__ = "<NAME>"

import logging
import subprocess
import unittest


class TestAuthlistFunc(unittest.TestCase):

    def setUp(self):
        input = 'data/example_author_list.csv'

        self.csv = 'test_author_list.csv'
        self.tex = self.csv.replace('.csv','.tex')
        self.aux = self.csv.replace('.csv','.aux')
        self.log = self.csv.replace('.csv','.log')
        self.bib = self.csv.replace('.csv','*.bib')
        self.pdf = self.csv.replace('.csv','.pdf')
        self.cls = ['emulateapj.cls','mnras.cls','aastex.cls']

        self.files = dict(self.__dict__)

        cmd = "cp %s %s"%(input,self.csv)
        print(cmd)
        subprocess.check_output(cmd,shell=True)
         
        cmd = "cp %s ."%(' '.join(['data/%s'%c for c in self.cls]))
        print(cmd)
        subprocess.check_output(cmd,shell=True)

    def tearDown(self):
        self.clean = [self.csv,self.tex,self.aux,self.log,self.bib,self.pdf] 
        self.clean += self.cls

        cmd = "rm -f "+' '.join(self.clean)
        print(cmd)
        subprocess.check_output(cmd,shell=True)

    def latex(self, tex=None):
        if tex is None: tex = self.tex

        cmd = "pdflatex -interaction=nonstopmode %s"%(tex)
        print(cmd)
        subprocess.check_output(cmd,shell=True)

    def test_mkauthlist(self):
        cmd = "mkauthlist -f --doc %(csv)s %(tex)s"%self.files
        print(cmd)
        subprocess.check_output(cmd,shell=True)
        
        self.latex()

        cmd = 'cp %s %s'%(self.pdf,'test_mkauthlist.pdf')
        print(cmd)
        subprocess.check_output(cmd,shell=True)

    def test_emulateapj(self):
        cmd = "mkauthlist -f --doc -j emulateapj %(csv)s %(tex)s"%self.files
        print(cmd)
        subprocess.check_output(cmd,shell=True)

        self.latex()

        cmd = 'cp %s %s'%(self.pdf,'test_emulateapj.pdf')
        print(cmd)
        subprocess.check_output(cmd,shell=True)
     
    def test_mnras(self):
        cmd = "mkauthlist -f --doc -j mnras %(csv)s %(tex)s"%self.files
        print(cmd)
        subprocess.check_output(cmd,shell=True)

        self.latex()

        cmd = 'cp %s %s'%(self.pdf,'test_mnras.pdf')
        print(cmd)
        subprocess.check_output(cmd,shell=True)
     
    def test_aastex(self):
        cmd = "mkauthlist -f --doc -j aastex %(csv)s %(tex)s"%self.files
        print(cmd)
        subprocess.check_output(cmd,shell=True)

        self.latex()

        cmd = 'cp %s %s'%(self.pdf,'test_aastex.pdf')
        print(cmd)
        subprocess.check_output(cmd,shell=True)

    def test_revtex(self):
        cmd = "mkauthlist -f --doc -j revtex %(csv)s %(tex)s"%self.files
        print(cmd)
        subprocess.check_output(cmd,shell=True)

        self.latex()

        cmd = 'cp %s %s'%(self.pdf,'test_revtex.pdf')
        print(cmd)
        subprocess.check_output(cmd,shell=True)
    
if __name__ == "__main__":
    unittest.main()<commit_msg>Clean up file copying in tests<commit_after>#!/usr/bin/env python
"""
Python test script
"""
__author__ = "<NAME>"
import os
import shutil
import logging
import subprocess
import unittest

class TestAuthlistFunc(unittest.TestCase):

    def setUp(self):
        self.csv = 'example_author_list.csv'
        self.cls = ['emulateapj.cls','mnras.cls','aastex.cls']
        self.tex = self.csv.replace('.csv','.tex')
        self.aux = self.csv.replace('.csv','.aux')
        self.out = self.csv.replace('.csv','.out')
        self.log = self.csv.replace('.csv','.log')
        self.bib = self.csv.replace('.csv','*.bib')
        self.pdf = self.csv.replace('.csv','.pdf')

        self.files = dict(self.__dict__)

        for filename in [self.csv]+self.cls:
            shutil.copy(os.path.join('data',filename),'.')

    def tearDown(self):
        self.clean = [self.csv,self.tex,self.aux,self.log,self.bib,self.pdf] 
        self.clean += self.cls

        cmd = "rm -f "+' '.join(self.clean)
        print(cmd)
        subprocess.check_output(cmd,shell=True)

    def latex(self, tex=None, pdf=None):
        if tex is None: tex = self.tex
        if pdf is None: pdf = self.pdf

        cmd = "pdflatex -interaction=nonstopmode %s"%(tex)
        print(cmd)
        subprocess.check_output(cmd,shell=True)
        shutil.copy(tex.replace('.tex','.pdf'),pdf)
        
    def test_mkauthlist(self):
        cmd = "mkauthlist -f --doc %(csv)s %(tex)s"%self.files
        print(cmd)
        subprocess.check_output(cmd,shell=True)
        self.latex(pdf='test_mkauthlist.pdf')

    def test_emulateapj(self):
        cmd = "mkauthlist -f --doc -j emulateapj %(csv)s %(tex)s"%self.files
        print(cmd)
        subprocess.check_output(cmd,shell=True)
        self.latex(pdf='test_emulateapj.pdf')
     
    def test_mnras(self):
        cmd = "mkauthlist -f --doc -j mnras %(csv)s %(tex)s"%self.files
        print(cmd)
        subprocess.check_output(cmd,shell=True)
        self.latex(pdf='test_mnras.pdf')
     
    def test_aastex(self):
        cmd = "mkauthlist -f --doc -j aastex %(csv)s %(tex)s"%self.files
        print(cmd)
        subprocess.check_output(cmd,shell=True)
        self.latex(pdf='test_aastex.pdf')

    def test_revtex(self):
        cmd = "mkauthlist -f --doc -j revtex %(csv)s %(tex)s"%self.files
        print(cmd)
        subprocess.check_output(cmd,shell=True)
        self.latex(pdf='test_revtex.pdf')
    
if __name__ == "__main__":
    unittest.main()
{'fraction_non_alphanumeric': 0.15998542274052477, 'fraction_numerical': 0.0, 'mean_word_length': 2.4652777777777777, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '3773393', 'n_tokens_mistral': 1969, 'n_tokens_neox': 1931, 'n_words': 325}