<commit_before>import unittest
import env
import os
import shutil
import subprocess
from time import sleep


class TestRunnerForScanner(unittest.TestCase):

    def setUp(self):
        self.db_dir = os.path.join(
            env.RESULTS_DIR,
            'scanner',
            'db_dir'
        )
        self.real_suite = os.path.join(
            env.TEST_DATA_DIR,
            'suite_tree')
        if os.path.exists(self.db_dir):
            while os.path.exists(self.db_dir):
                shutil.rmtree(self.db_dir)
                sleep(0.1)
            os.mkdir(self.db_dir)
            sleep(0.1)
        self.workspace = env.TEST_DATA_DIR
        self.runner = os.path.join(env.SRC_DIR, 'run_scanner.py')

    def test_scan_all(self):
        p_args = [
            'python',
            self.runner,
            'all',
            '--workspace',
            self.workspace,
            '--extension',
            'robot',
            '--db_path',
            self.db_dir]
        self.run_process(p_args)
        files = os.listdir(self.db_dir)
        self.assertEqual(len(files), 22)

    def test_scan_errors(self):
        p_args = [
            'python',
            self.runner,
            'all',
            '--db_path',
            self.db_dir]
        log_file = self.run_process(p_args)
        f = open(log_file)
        self.assertTrue(f.readlines()[-1].startswith('ValueError'))
        f.close()

        p_args = [
            'python',
            self.runner,
            'all',
            '--workspace',
            self.workspace,
            '--db_path',
            self.db_dir]
        log_file = self.run_process(p_args)
        f = open(log_file)
        self.assertTrue(f.readlines()[-1].startswith('ValueError'))
        f.close()

        p_args = [
            'python',<commit_msg>Added more realistic suite for scanner runner test<commit_after>import unittest
import env
import os
import shutil
import subprocess
from time import sleep


class TestRunnerForScanner(unittest.TestCase):

    def setUp(self):
        self.db_dir = os.path.join(
            env.RESULTS_DIR,
            'scanner',
            'db_dir'
        )
        if os.path.exists(self.db_dir):
            while os.path.exists(self.db_dir):
                shutil.rmtree(self.db_dir)
                sleep(0.1)
            os.mkdir(self.db_dir)
        self.workspace = os.path.join(env.TEST_DATA_DIR, 'suite_tree')
        self.runner = os.path.join(env.SRC_DIR, 'run_scanner.py')

    def test_scan_all(self):
        p_args = [
            'python',
            self.runner,
            'all',
            '--workspace',
            self.workspace,
            '--extension',
            'robot',
            '--db_path',
            self.db_dir]
        self.run_process(p_args)
        files = os.listdir(self.db_dir)
        self.assertEqual(len(files), 10)

    def test_scan_errors(self):
        p_args = [
            'python',
            self.runner,
            'all',
            '--db_path',
            self.db_dir]
        log_file = self.run_process(p_args)
        f = open(log_file)
        self.assertTrue(f.readlines()[-1].startswith('ValueError'))
        f.close()

        p_args = [
            'python',
            self.runner,
            'all',
            '--workspace',
            self.workspace,
            '--db_path',
            self.db_dir]
        log_file = self.run_process(p_args)
        f = open(log_file)
        self.assertTrue(f.readlines()[-1].startswith('ValueError'))
        f.close()

        p_args = [
            'python',
{'fraction_non_alphanumeric': 0.12016689847009736, 'fraction_numerical': 0.003894297635605007, 'mean_word_length': 1.48, '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': '1175071', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1123, 'n_words': 176}