<commit_before>import unittest

import mongoext.fields as fields


class TestNumericField(unittest.TestCase):
    def setUp(self):
        self.field = fields.Numeric()

    def test_str_number(self):
        self.assertEqual(self.field('1'), 1)

    def test_unsupported_str(self):
        with self.assertRaises(ValueError):
            self.field('a')


class TestNumericListField(unittest.TestCase):
    def setUp(self):
        self.field = fields.List(fields.Numeric())

    def test_list_of_valid_strings(self):
        self.assertEqual(self.field(['1', '2']), [1, 2])

    def test_empty_list(self):
        self.assertEqual(self.field([]), [])

    def test_list_of_invalid_strings(self):
        with self.assertRaises(ValueError):
            self.assertEqual(self.field(['a', '2']), ['a', 2])

    def test_non_iteratable_none(self):
        with self.assertRaises(ValueError):
            self.field(None)

    def test_non_iterable_int(self):
        with self.assertRaises(ValueError):
            self.field(1)


class TestStringListField(unittest.TestCase):
    def setUp(self):
        self.fields = fields.List(fields.String())<commit_msg>add tests for list without fields<commit_after>import unittest

import mongoext.fields as fields


class TestNumericField(unittest.TestCase):
    def setUp(self):
        self.field = fields.Numeric()

    def test_str_number(self):
        self.assertEqual(self.field('1'), 1)

    def test_unsupported_str(self):
        with self.assertRaises(ValueError):
            self.field('a')


class TestNumericListField(unittest.TestCase):
    def setUp(self):
        self.field = fields.List(fields.Numeric())

    def test_list_of_valid_strings(self):
        self.assertEqual(self.field(['1', '2']), [1, 2])

    def test_empty_list(self):
        self.assertEqual(self.field([]), [])

    def test_list_of_invalid_strings(self):
        with self.assertRaises(ValueError):
            self.assertEqual(self.field(['a', '2']), ['a', 2])

    def test_non_iterable_none(self):
        with self.assertRaises(ValueError):
            self.field(None)

    def test_non_iterable_int(self):
        with self.assertRaises(ValueError):
            self.field(1)


class TestStringListField(unittest.TestCase):
    def setUp(self):
        self.fields = fields.List(fields.String())


class TestList(unittest.TestCase):
    def setUp(self):
        self.field = fields.List()

    def test_random_values(self):
        self.assertEqual(self.field([1, '1']), [1, '1'])

    def test_empty_list(self):
        self.assertEqual(self.field([]), [])

    def test_non_iterable_none(self):
        with self.assertRaises(ValueError):
            self.field(None)

    def test_non_iterable_int(self):
        with self.assertRaises(ValueError):
            self.field(1)
{'fraction_non_alphanumeric': 0.1299715909090909, 'fraction_numerical': 0.008167613636363636, 'mean_word_length': 3.1548672566371683, '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': '7109816', 'n_tokens_mistral': 907, 'n_tokens_neox': 875, 'n_words': 149}