コード例 #1
0
ファイル: test_equal.py プロジェクト: vesln/robber.py
 def test_with_unicode_string(self, mock_unicode_string_to_str):
     Equal.unicode_to_str(u'Mèo')
     # python <= 2.7
     if sys.version_info[0] < 3:
         mock_unicode_string_to_str.assert_called_with(u'Mèo')
     else:
         mock_unicode_string_to_str.assert_not_called()
コード例 #2
0
 def test_with_unicode_dict(self, mock_unicode_dict_to_str_dict):
     u_dict = {
         'cat': u'Mèo',
         'dog': u'Chó',
     }
     Equal.unicode_to_str(u_dict)
     mock_unicode_dict_to_str_dict.assert_called_with(u_dict)
コード例 #3
0
ファイル: test_equal.py プロジェクト: vesln/robber.py
 def test_with_unicode_dict(self, mock_unicode_dict_to_str_dict):
     u_dict = {
         'cat': u'Mèo',
         'dog': u'Chó',
     }
     Equal.unicode_to_str(u_dict)
     mock_unicode_dict_to_str_dict.assert_called_with(u_dict)
コード例 #4
0
 def test_with_unicode_string(self, mock_unicode_string_to_str):
     Equal.unicode_to_str(u'Mèo')
     # python <= 2.7
     if sys.version_info[0] < 3:
         mock_unicode_string_to_str.assert_called_with(u'Mèo')
     else:
         mock_unicode_string_to_str.assert_not_called()
コード例 #5
0
    def test_unicode_dict_to_str_dict(self, mock_unicode_to_str):
        u_dict = {
            'cat': u'Mèo',
            'dog': u'Chó',
        }

        Equal._unicode_dict_to_str_dict(u_dict)

        mock_unicode_to_str.assert_any_call(u'Mèo')
        mock_unicode_to_str.assert_any_call(u'Chó')
コード例 #6
0
ファイル: test_equal.py プロジェクト: vesln/robber.py
    def test_unicode_dict_to_str_dict(self, mock_unicode_to_str):
        u_dict = {
            'cat': u'Mèo',
            'dog': u'Chó',
        }

        Equal._unicode_dict_to_str_dict(u_dict)

        mock_unicode_to_str.assert_any_call(u'Mèo')
        mock_unicode_to_str.assert_any_call(u'Chó')
コード例 #7
0
 def test_if_unicode_dict_is_converted_to_str_dict(self):
     u_dict = {
         'cat': u'Mèo',
         'dog': u'Chó',
     }
     str_dict = {
         'cat': 'Mèo',
         'dog': 'Chó',
     }
     equal = Equal(u_dict, u_dict)
     equal.matches()
     self.assertEqual(equal.actual, str_dict)
     self.assertEqual(equal.expected, str_dict)
コード例 #8
0
ファイル: test_equal.py プロジェクト: vesln/robber.py
 def test_if_unicode_dict_is_converted_to_str_dict(self):
     u_dict = {
         'cat': u'Mèo',
         'dog': u'Chó',
     }
     str_dict = {
         'cat': 'Mèo',
         'dog': 'Chó',
     }
     equal = Equal(u_dict, u_dict)
     equal.matches()
     self.assertEqual(equal.actual, str_dict)
     self.assertEqual(equal.expected, str_dict)
コード例 #9
0
    def test_if_ordered_dict_is_converted_to_dict(self):
        try:
            from collections import OrderedDict
        except ImportError:
            pass
        else:
            d = {'a': '1', 'b': '2', 'c': '3'}
            od = OrderedDict(d)

            equal = Equal(od, od)
            equal.matches()

            self.assertEqual(equal.actual, d)
            self.assertEqual(equal.expected, d)
コード例 #10
0
ファイル: test_equal.py プロジェクト: vesln/robber.py
    def test_if_ordered_dict_is_converted_to_dict(self):
        try:
            from collections import OrderedDict
        except ImportError:
            pass
        else:
            d = {'a': '1', 'b': '2', 'c': '3'}
            od = OrderedDict(d)

            equal = Equal(od, od)
            equal.matches()

            self.assertEqual(equal.actual, d)
            self.assertEqual(equal.expected, d)
コード例 #11
0
    def test_explanation_message_with_two_lists(self, mock_list_diffs):
        mock_list_diffs.return_value = 'Some diffs'
        l1 = [1, 2]
        l2 = [1, 3]
        equal = Equal(l1, l2)

        expect('Some diffs' in equal.explanation.message).to.eq(True)
コード例 #12
0
    def test_explanation_message_with_two_strings(self, mock_str_diffs):
        mock_str_diffs.return_value = 'Some diffs'
        l1 = 'cat'
        l2 = 'dog'
        equal = Equal(l1, l2)

        expect('Some diffs' in equal.explanation.message).to.eq(True)
コード例 #13
0
    def test_explanation_message_with_two_dicts(self, mock_dict_diffs):
        mock_dict_diffs.return_value = 'Some diffs'
        d1 = {'a': 1, 'c': 2}
        d2 = {'a': 1, 'b': 3}
        equal = Equal(d1, d2)

        expect('Some diffs' in equal.explanation.message).to.eq(True)
コード例 #14
0
    def test_positive_explanation_message(self):
        equal = Equal('123', 123)
        message = equal.explanation.message
        expect(message).to.eq("""
A = '123'
B = 123
Expected A to equal B
""")
コード例 #15
0
    def test_dict_diffs_with_different_value(self):
        d1 = {'a': 1, 'b': 2}
        d2 = {'a': 1, 'b': 3}
        equal = Equal(d1, d2)
        expect(equal.dict_diffs).to.eq("""Diffs:
A['b'] = 2
B['b'] = 3
""")
コード例 #16
0
    def test_negative_explanation_message(self):
        equal = Equal('actual', 'actual', is_negative=True)
        message = equal.explanation.message
        expect(message).to.eq("""
A = actual
B = actual
Expected A not to equal B
""")
コード例 #17
0
    def test_str_diff_with_strings(self):
        equal = Equal('A little cat', 'A little dog', is_negative=False)
        expect(equal.str_diffs).to.eq("""Diffs:
- A little cat
?          ^^^

+ A little dog
?          ^^^
""")
コード例 #18
0
 def test_with_unicode_list(self, mock_unicode_list_to_str_list):
     Equal.unicode_to_str([u'Mèo', u'Chó'])
     mock_unicode_list_to_str_list.assert_called_with([u'Mèo', u'Chó'])
コード例 #19
0
ファイル: test_equal.py プロジェクト: vesln/robber.py
 def test_unicode_list_to_str_list(self, mock_unicode_to_str):
     Equal._unicode_list_to_str_list([u'Mèo', u'Chó'])
     mock_unicode_to_str.assert_any_call(u'Mèo')
     mock_unicode_to_str.assert_any_call(u'Chó')
コード例 #20
0
ファイル: test_equal.py プロジェクト: vesln/robber.py
 def test_unicode_string_to_str(self):
     self.assertEqual(Equal._unicode_string_to_str(u'Mèo'), u'Mèo'.encode('utf-8'))
コード例 #21
0
 def test_matches(self):
     expect(Equal(1, 1).matches()).to.eq(True)
     expect(Equal(1, 2).matches()).to.eq(False)
コード例 #22
0
 def test_if_unicode_string_is_converted_to_str(self):
     equal = Equal(u'Mèo', u'Mèo')
     equal.matches()
     self.assertEqual(equal.actual, 'Mèo')
     self.assertEqual(equal.expected, 'Mèo')
コード例 #23
0
ファイル: test_equal.py プロジェクト: vesln/robber.py
 def test_if_unicode_list_is_converted_to_str_list(self):
     equal = Equal([u'Mèo', u'Chó'], [u'Mèo', u'Chó'])
     equal.matches()
     self.assertEqual(equal.actual, ['Mèo', 'Chó'])
     self.assertEqual(equal.expected, ['Mèo', 'Chó'])
コード例 #24
0
ファイル: test_equal.py プロジェクト: vesln/robber.py
 def test_if_unicode_string_is_converted_to_str(self):
     equal = Equal(u'Mèo', u'Mèo')
     equal.matches()
     self.assertEqual(equal.actual, 'Mèo')
     self.assertEqual(equal.expected, 'Mèo')
コード例 #25
0
 def test_dict_diffs_with_different_length(self):
     d1 = {'a': 1}
     d2 = {'a': 1, 'b': 2}
     equal = Equal(d1, d2)
     expect(equal.dict_diffs).to.eq('A and B does not have the same length')
コード例 #26
0
 def test_unicode_list_to_str_list(self, mock_unicode_to_str):
     Equal._unicode_list_to_str_list([u'Mèo', u'Chó'])
     mock_unicode_to_str.assert_any_call(u'Mèo')
     mock_unicode_to_str.assert_any_call(u'Chó')
コード例 #27
0
 def test_dict_diffs_with_different_key(self):
     d1 = {'a': 1, 'c': 2}
     d2 = {'a': 1, 'b': 2}
     equal = Equal(d1, d2)
     expect(equal.dict_diffs).to.eq("A has key 'c' while B does not")
コード例 #28
0
 def test_matches(self):
     expect(Equal(1, 1).matches()) == True
     expect(Equal(1, 2).matches()) == False
コード例 #29
0
 def test_if_unicode_list_is_converted_to_str_list(self):
     equal = Equal([u'Mèo', u'Chó'], [u'Mèo', u'Chó'])
     equal.matches()
     self.assertEqual(equal.actual, ['Mèo', 'Chó'])
     self.assertEqual(equal.expected, ['Mèo', 'Chó'])
コード例 #30
0
 def test_unicode_string_to_str(self):
     self.assertEqual(Equal._unicode_string_to_str(u'Mèo'),
                      u'Mèo'.encode('utf-8'))
コード例 #31
0
ファイル: test_equal.py プロジェクト: vesln/robber.py
 def test_with_unicode_list(self, mock_unicode_list_to_str_list):
     Equal.unicode_to_str([u'Mèo', u'Chó'])
     mock_unicode_list_to_str_list.assert_called_with([u'Mèo', u'Chó'])
コード例 #32
0
 def test_list_diffs_with_different_length(self):
     l1 = [1]
     d2 = [1, 2]
     equal = Equal(l1, d2)
     expect(equal.list_diffs).to.eq('A and B do not have the same length')
コード例 #33
0
 def test_failure_message(self):
     equal = Equal('actual', 'expected')
     message = equal.failure_message()
     expect(message) == 'Expected "actual" to equal "expected"'
コード例 #34
0
 def test_list_diffs_with_different_member(self):
     l1 = [1, 2]
     d2 = [1, 3]
     equal = Equal(l1, d2)
     expect(equal.list_diffs).to.eq("A contains 2 while B does not")
コード例 #35
0
ファイル: test_equal.py プロジェクト: rlgomes/robber.py
 def test_failure_message(self):
     equal = Equal('actual', 'expected')
     message = equal.failure_message()
     expect(message) == 'Expected "actual" to equal "expected"'
コード例 #36
0
 def test_str_diff_with_two_equal_strings(self):
     equal = Equal('a', 'a', is_negative=True)
     expect(equal.str_diffs).to.eq('')