<commit_before>from queue import Queue
import sys

sys.path.insert(0, ".")
import unittest
from coalib.settings.Setting import Setting
from bears.tests.LocalBearTestHelper import LocalBearTestHelper
from bears.spacing.SpaceConsistencyBear import (SpaceConsistencyBear,
                                                SpacingHelper)
from coalib.settings.Section import Section


class SpaceConsistencyBearTest(LocalBearTestHelper):
    def setUp(self):
        self.section = Section("test section")
        self.uut = SpaceConsistencyBear(self.section, Queue())

    def test_needed_settings(self):
        self.section.append(Setting("use_spaces", "true"))

        needed_settings = self.uut.get_non_optional_settings()
        self.assertEqual(len(needed_settings),
                         1 + len(SpacingHelper.get_non_optional_settings()))
        self.assertIn("use_spaces", needed_settings)

    def test_data_sets_spaces(self):
        self.section.append(Setting("use_spaces", "true"))

        self.assertLineValid(self.uut, "    t")
        self.assertLineInvalid(self.uut, "t \n")
        self.assertLineInvalid(self.uut, "\tt\n")

    def test_data_sets_tabs(self):
        self.section.append(Setting("use_spaces", "false"))
        self.section.append(Setting("allow_trailing_whitespace", "true"))

        self.assertLineInvalid(self.uut, "    t")
        self.assertLineValid(self.uut, "t \n")
        self.assertLineValid(self.uut, "\tt\n")


if __name__ == '__main__':
    unittest.main(verbosity=2)<commit_msg>SpaceConsistencyBearTest: Explicitly set settings<commit_after>from queue import Queue
import sys

sys.path.insert(0, ".")
import unittest
from coalib.settings.Setting import Setting
from bears.tests.LocalBearTestHelper import LocalBearTestHelper
from bears.spacing.SpaceConsistencyBear import (SpaceConsistencyBear,
                                                SpacingHelper)
from coalib.settings.Section import Section


class SpaceConsistencyBearTest(LocalBearTestHelper):
    def setUp(self):
        self.section = Section("test section")
        self.uut = SpaceConsistencyBear(self.section, Queue())

    def test_needed_settings(self):
        self.section.append(Setting("use_spaces", "true"))

        needed_settings = self.uut.get_non_optional_settings()
        self.assertEqual(len(needed_settings),
                         1 + len(SpacingHelper.get_non_optional_settings()))
        self.assertIn("use_spaces", needed_settings)

    def test_data_sets_spaces(self):
        self.section.append(Setting("use_spaces", "true"))
        self.section.append(Setting("allow_trailing_whitespace", "false"))
        self.section.append(Setting("enforce_newline_at_EOF", "false"))

        self.assertLineValid(self.uut, "    t")
        self.assertLineInvalid(self.uut, "t \n")
        self.assertLineInvalid(self.uut, "\tt\n")

    def test_data_sets_tabs(self):
        self.section.append(Setting("use_spaces", "false"))
        self.section.append(Setting("allow_trailing_whitespace", "true"))
        self.section.append(Setting("enforce_newline_at_EOF", "false"))

        self.assertLineInvalid(self.uut, "    t")
        self.assertLineValid(self.uut, "t \n")
        self.assertLineValid(self.uut, "\tt\n")


if __name__ == '__main__':
    unittest.main(verbosity=2)
{'fraction_non_alphanumeric': 0.11576725957190231, 'fraction_numerical': 0.0018088634308109737, 'mean_word_length': 3.388888888888889, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6073208', 'n_tokens_mistral': 1027, 'n_tokens_neox': 991, 'n_words': 158}