<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

##
# python standard library
#
import unittest
from functools import partial


##
# test helper
#
from testutils import mock


##
# content bits modules
#
from pycomber.strategies import MergeAbstract, MergeList, MergeListOverride, \
    MergeSet, MergeSetOverride, MergeDict, MergeDictOverride, MergePrimitives, \
    MergeNone


class MergeTestMixin(object):

    def setUp(self):
        self.manager = mock.Mock(side_effect = lambda a, b=None: a)
        self.merger = self.merger_class(self.manager)

    def test_init_requires_one_argument(self):
        self.assertRaises(TypeError, self.merger_class)
        err = False
        try:
            self.merger_class(None)
        except AttributeError:
            err = True
        self.assertFalse(err)

    def test_instance_is_callable(self):
        self.assertTrue(hasattr(self.merger, '__call__'))

    def test_call_expects_2_arguments(self):
        self.assertRaises(TypeError, self.merger)
        self.assertRaises(TypeError, partial(self.merger, None))
        err=False
        try:
            self.merger(None, None)
        except TypeError:
            err=True
        except:
            pass
        self.assertFalse(err)
        self.assertRaises(TypeError, partial(self.merger, None, None, None))


class MergeAbstractTestCase(unittest.TestCase, MergeTestMixin):

    def setUp(self):
        self.merger_class = MergeAbstract
        MergeTestMixin.setUp(self)

    def test_call_must_be_implemented(self):
        self.assertRaises(RuntimeError, partial(self.merger, None, None))


class MergeNoneTestCase(unittest.TestCase, MergeTestMixin):

    def setUp(self):
        self.merger_class = MergeNone
        MergeTestMixin.setUp(self)

    def test_non_None_arguments_is_returned(self):
        self.assertEqual(self.merger(None, 'b'), 'b')
        self.assertEqual(self.merger('a', None), 'a')
        self.assertEqual(self.merger('a', 'b'), 'a')
        self.assertEqual(self.merger(None, None), None)<commit_msg>Fixed check for type error caused by incorrect number of variables<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

##
# python standard library
#
import unittest
from functools import partial


##
# test helper
#
from testutils import mock


##
# content bits modules
#
from pycomber.strategies import MergeAbstract, MergeList, MergeListOverride, \
    MergeSet, MergeSetOverride, MergeDict, MergeDictOverride, MergePrimitives, \
    MergeNone


class MergeTestMixin(object):

    def setUp(self):
        self.manager = mock.Mock(side_effect = lambda a, b=None: a)
        self.merger = self.merger_class(self.manager)

    def test_init_requires_one_argument(self):
        self.assertRaises(TypeError, self.merger_class)
        err = False
        try:
            self.merger_class(None)
        except AttributeError:
            err = True
        self.assertFalse(err)

    def test_instance_is_callable(self):
        self.assertTrue(hasattr(self.merger, '__call__'))

    def test_call_expects_2_arguments(self):
        self.assertRaises(TypeError, self.merger)
        self.assertRaises(TypeError, partial(self.merger, None))
        err=False
        try:
            self.merger(None, None)
        except TypeError, e:
            err='takes exactly ' in e.args[0]
        except:
            pass
        self.assertFalse(err)
        self.assertRaises(TypeError, partial(self.merger, None, None, None))


class MergeAbstractTestCase(unittest.TestCase, MergeTestMixin):

    def setUp(self):
        self.merger_class = MergeAbstract
        MergeTestMixin.setUp(self)

    def test_call_must_be_implemented(self):
        self.assertRaises(RuntimeError, partial(self.merger, None, None))


class MergeNoneTestCase(unittest.TestCase, MergeTestMixin):

    def setUp(self):
        self.merger_class = MergeNone
        MergeTestMixin.setUp(self)

    def test_non_None_arguments_is_returned(self):
        self.assertEqual(self.merger(None, 'b'), 'b')
        self.assertEqual(self.merger('a', None), 'a')
        self.assertEqual(self.merger('a', 'b'), 'a')
        self.assertEqual(self.merger(None, None), None)
{'fraction_non_alphanumeric': 0.10421127765881513, 'fraction_numerical': 0.0011896264572924102, 'mean_word_length': 3.0855199222546164, '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': '7452060', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1311, 'n_words': 255}