<commit_before>from sequana.scripts import main
from nose.plugins.attrib import attr
import mock


class TestPipeline(object):

    @classmethod
    def setup_class(klass):
        """This method is run once for each class before any tests are run"""
        klass.prog = "sequana"
        klass.params = {'prog': klass.prog}

    @classmethod
    def teardown_class(klass):
        """This method is run once for each class _after_ all tests are run"""
        import os
        # local nosetests execution
        try:os.remove('README')
        except:pass
        try:os.remove('quality.rules')
        except:pass
        try:os.remove('config.yaml')
        except:pass


    def setUp(self):
        """This method is run once before _each_ test method is executed"""

    def teardown(self):
        """This method is run once after _each_ test method is executed"""

    def test_version(self):
        main.main([self.prog, '--version'])

    def test_init(self):
        try:
            # py3
            with mock.patch('builtins.input', return_value="y"):
                main.main([self.prog, '--pipeline', "quality", "--force-init"])

            with mock.patch('builtins.input', return_value="y"):
                try:
                    main.main([self.prog, '--pipeline', "qualitydummy"])
                    assert False
                except:
                    assert True
        except:
            # py2
            with mock.patch('__builtin__.input', return_value="y"):
                main.main([self.prog, '--pipeline', "quality"])

            with mock.patch('__builtin__.input', return_value="y"):
                try:
                    main.main([self.prog, '--pipeline', "qualitydummy"])
                    assert False
                except:
                    assert True

        #main.main([self.prog, '--pipeline', "quality", "--force-init"])

    def test_run(self):
        pass

    def test_help(self):
        try:
            main.main([self.prog, '--help'])
            assert False
        except SystemExit:
            pass
        else:
            raise Exception

    @attr('onweb')
    def test_info(self):
        main.main([self.prog, '--info', "quality"])

    def test_show_pipelines(self):
        main.main([self.prog, '--show-pipelines'])

    def test_mutually_exclusive(self):
        try:
            main.main([self.prog, '--pipeline', 'quality', '--info'])
            assert False
        except:
            assert True

<commit_msg>more tests and better cleanup<commit_after>from sequana.scripts import main
from nose.plugins.attrib import attr
import mock
from sequana import sequana_data

class TestPipeline(object):

    @classmethod
    def setup_class(klass):
        """This method is run once for each class before any tests are run"""
        klass.prog = "sequana"
        klass.params = {'prog': klass.prog}

    @classmethod
    def teardown_class(klass):
        """This method is run once for each class _after_ all tests are run"""
        import os
        # local nosetests execution
        #try:os.remove('README')
        #except:pass
        try:os.remove('quality.rules')
        except:pass
        try:os.remove('config.yaml')
        except:pass

        import shutil
        try:shutil.rmtree("Hm2_test")
        except:pass
        
        try:shutil.rmtree("report")
        except:pass

    def setUp(self):
        """This method is run once before _each_ test method is executed"""

    def teardown(self):
        """This method is run once after _each_ test method is executed"""

    def test_version(self):
        main.main([self.prog, '--version'])

    def test_init(self):
        try:
            # py3

            with mock.patch('builtins.input', return_value="y"):
                try:
                    main.main([self.prog, '--pipeline', "qualitydummy"])
                    assert False
                except:
                    assert True
        except:
            # py2
            with mock.patch('__builtin__.input', return_value="y"):
                main.main([self.prog, '--pipeline', "quality"])

            with mock.patch('__builtin__.input', return_value="y"):
                try:
                    main.main([self.prog, '--pipeline', "qualitydummy"])
                    assert False
                except:
                    assert True


    def test_run(self):
        pass

    def test_help(self):
        try:
            main.main([self.prog, '--help'])
            assert False
        except SystemExit:
            pass
        else:
            raise Exception

    @attr('onweb')
    def test_info(self):
        main.main([self.prog, '--info', "quality"])

    def test_show_pipelines(self):
        main.main([self.prog, '--show-pipelines'])

    def test_mutually_exclusive(self):
        try:
            main.main([self.prog, '--pipeline', 'quality', '--info'])
            assert False
        except:
            assert True


    def test_input(self):
        file1 = sequana_data('Hm2_GTGAAA_L005_R1_001.fastq.gz', 'data')
        file2 = sequana_data('Hm2_GTGAAA_L005_R2_001.fastq.gz', 'data')
        main.main([self.prog, "--pipeline", "quality", "--file1", file1,
"--file2", file2, "--project", "Hm2_test"])
        




{'fraction_non_alphanumeric': 0.12332389046270066, 'fraction_numerical': 0.005288007554296506, 'mean_word_length': 1.8170212765957447, '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': '2476868', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1478, 'n_words': 370}