<commit_before>__author__ = 'dcl9'
import yaml
import unittest
from tag_handlers import configure


class TagHandlersTestCase(unittest.TestCase):
    def setUp(self):
        self.var_map = {'VAR1': 'val1', 'VAR2': 'val2'}
        configure(self.var_map)

    def load(self, document):
        self.loaded = yaml.load(document)

    def check(self, message):
        self.assertEqual(self.expected, self.loaded, message)

    def test_var(self):
        """
        Test variable interpolation
        """
        self.load('k: !var VAR1')
        self.expected = {'k': self.var_map['VAR1']}
        self.check('Variable interpolation with !var failed')

    def test_join(self):
        """
        Test joining values
        """
        self.load('k: !join [foo, bar]')
        self.expected = {'k': 'foobar'}
        self.check('Join Values with !join failed')

    def test_change_ext(self):
        """
        Test changing file extension
        """
        self.load('k: !change_ext foo.bar baz')
        self.expected = {'k': 'foo.baz'}
        self.check('Changing file extension with !change_ext failed')

    def test_base(self):
        """
        Test getting base name of file
        """
        self.load('k: !base /path/to/bar')
        self.expected = {'k': 'bar'}
        self.check('Getting basename with !base failed')


if __name__ == '__main__':
    unittest.main()
<commit_msg>Add tests combining multiple tags<commit_after>__author__ = 'dcl9'
import yaml
import unittest
from tag_handlers import configure


class TagHandlersTestCase(unittest.TestCase):
    def setUp(self):
        self.var_map = {'VAR1': 'val1', 'VAR2': 'val2'}
        configure(self.var_map)

    def load(self, document):
        self.loaded = yaml.load(document)

    def check(self, message):
        self.assertEqual(self.expected, self.loaded, message)

    def test_var(self):
        """
        Test variable interpolation
        """
        self.load('k: !var VAR1')
        self.expected = {'k': self.var_map['VAR1']}
        self.check('Variable interpolation with !var failed')

    def test_join(self):
        """
        Test joining values
        """
        self.load('k: !join [foo, bar]')
        self.expected = {'k': 'foobar'}
        self.check('Join Values with !join failed')

    def test_change_ext(self):
        """
        Test changing file extension
        """
        self.load('k: !change_ext foo.bar baz')
        self.expected = {'k': 'foo.baz'}
        self.check('Changing file extension with !change_ext failed')

    def test_base(self):
        """
        Test getting base name of file
        """
        self.load('k: !base /path/to/bar')
        self.expected = {'k': 'bar'}
        self.check('Getting basename with !base failed')

    def test_join_and_var(self):
        """
        Test join and var
        """
        self.load('k: !join [!var VAR1, !var VAR2]')
        self.expected = {'k': 'val1val2'}
        self.check('Combining !join and !var')

    def test_change_ext_and_base(self):
        """
        Test change_ext and base
        """
        self.load('k: !change_ext [!base /path/to/file.abc, def]')
        self.expected = {'k': 'file.def'}
        self.check('Combining !change_ext and !base')

if __name__ == '__main__':
    unittest.main()

{'fraction_non_alphanumeric': 0.14061557030778515, 'fraction_numerical': 0.005431502715751358, 'mean_word_length': 2.335010060362173, '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': '1317040', 'n_tokens_mistral': 1036, 'n_tokens_neox': 1002, 'n_words': 253}