'Test NumDict constructors'

def test_constructors(self):

    dict_0 = {}
    dict_1 = {1: u'Elephant'}
    dict_2 = {1: u'Elephant', 2: u'Mouse'}
    dict_3 = {u'3': u'Aardvark'}
    dict_4 = {u'3': u'Aardvark', u'4': u'Ant'}
    dict_5 = {5: u'Cat', u'6': u'Dog'}
    dict_6 = {1: None, u'2': None}
    dict_7 = {None: u'Empty'}
    num_dict = NumDict()
    num_dict_0 = NumDict(dict_0)
    num_dict_1 = NumDict(dict_1)
    num_dict_2 = NumDict(dict_2)
    num_dict_3 = NumDict(dict_3)
    num_dict_4 = NumDict(dict_4)
    num_dict_5 = NumDict(dict_5)
    num_dict_6 = NumDict(dict_6)
    num_dict_7 = NumDict(dict_7)
    self.assertEqual(num_dict, {})
    self.assertEqual(num_dict_0, dict_0)
    self.assertEqual(num_dict_1, dict_1)
    self.assertEqual(num_dict_2, dict_2)
    self.assertNotEqual(num_dict_3, dict_3)
    self.assertNotEqual(num_dict_4, dict_4)
    self.assertNotEqual(num_dict_5, dict_5)
    self.assertNotEqual(num_dict_6, dict_6)
    self.assertEqual(num_dict_7, dict_7)
    dict_from_num_dict = dict(num_dict)
    dict_from_num_dict_1 = dict(num_dict_1)
    dict_from_num_dict_2 = dict(num_dict_2)
    dict_from_num_dict_3 = dict(num_dict_3)
    dict_from_num_dict_4 = dict(num_dict_4)
    dict_from_num_dict_5 = dict(num_dict_5)
    dict_from_num_dict_6 = dict(num_dict_6)
    dict_from_num_dict_7 = dict(num_dict_7)
    self.assertEqual(num_dict, dict_from_num_dict)
    self.assertEqual(num_dict_1, dict_from_num_dict_1)
    self.assertEqual(num_dict_2, dict_from_num_dict_2)
    self.assertEqual(num_dict_3, dict_from_num_dict_3)
    self.assertEqual(num_dict_4, dict_from_num_dict_4)
    self.assertEqual(num_dict_5, dict_from_num_dict_5)
    self.assertEqual(num_dict_6, dict_from_num_dict_6)
    self.assertEqual(num_dict_7, dict_from_num_dict_7)
    num_dict_from_num_dict = NumDict(num_dict)
    num_dict_from_num_dict_0 = NumDict(num_dict_0)
    num_dict_from_num_dict_1 = NumDict(num_dict_1)
    num_dict_from_num_dict_2 = NumDict(num_dict_2)
    num_dict_from_num_dict_3 = NumDict(num_dict_3)
    num_dict_from_num_dict_4 = NumDict(num_dict_4)
    num_dict_from_num_dict_5 = NumDict(num_dict_5)
    num_dict_from_num_dict_6 = NumDict(num_dict_6)
    num_dict_from_num_dict_7 = NumDict(num_dict_7)
    self.assertEqual(num_dict, num_dict_from_num_dict)
    self.assertEqual(num_dict_0, num_dict_from_num_dict_0)
    self.assertEqual(num_dict_1, num_dict_from_num_dict_1)
    self.assertEqual(num_dict_2, num_dict_from_num_dict_2)
    self.assertEqual(num_dict_3, num_dict_from_num_dict_3)
    self.assertEqual(num_dict_4, num_dict_from_num_dict_4)
    self.assertEqual(num_dict_5, num_dict_from_num_dict_5)
    self.assertEqual(num_dict_6, num_dict_from_num_dict_6)
    self.assertEqual(num_dict_7, num_dict_from_num_dict_7)
    with self.assertRaises(TypeError):
        NumDict(one=1, two=2)
    self.assertEqual(NumDict([(1, u'Elephant'), (2, u'Mouse')]), dict_from_num_dict_2)
    self.assertEqual(NumDict(dict=[(1, u'Elephant'), (2, u'Mouse')]), dict_from_num_dict_2)
    self.assertEqual(NumDict([(1, u'Elephant'), (u'2', u'Mouse')]), dict_from_num_dict_2)
    self.assertEqual(NumDict(dict=[(u'1', u'Elephant'), (2, u'Mouse')]), dict_from_num_dict_2)
    with self.assertRaises(TypeError):
        NumDict([(u'Rat', 11), (u'Snake', 12)])
    with self.assertRaises(TypeError):
        NumDict(dict=[(u'Rat', 11), (u'Snake', 12)])
    with self.assertRaises(TypeError):
        NumDict([(1, u'one'), (2, u'two')], two=3, five=4)
    dict_8 = {1: u'Echo', 2: u'Echo'}
    self.assertEqual(NumDict.fromkeys(u'1    2'.split()), dict_from_num_dict_6)
    self.assertEqual(NumDict().fromkeys(u'1    2'.split()), dict_from_num_dict_6)
    self.assertEqual(NumDict.fromkeys(u'1    2'.split(), u'Echo'), dict_8)
    self.assertEqual(NumDict().fromkeys(u'1    2'.split(), u'Echo'), dict_8)
    self.assertTrue((num_dict_1.fromkeys(u'1    2'.split()) is not num_dict_1))
    self.assertIsInstance(num_dict_1.fromkeys(u'1    2'.split()), NumDict)
    self.assertIsInstance(num_dict_2.fromkeys(u'1    2'.split()), NumDict)
    self.assertIsInstance(num_dict_3.fromkeys(u'1    2'.split()), NumDict)
    self.assertIsInstance(num_dict_4.fromkeys(u'1    2'.split()), NumDict)
