示例#1
0
    def explanation(self):
        if not self.actual.called:
            return Explanation(
                self.actual, self.is_negative, 'be called with', self.expected_args_str,
                more_detail='Actually not called', force_disable_repr=True
            )

        return Explanation(
            self.actual, self.is_negative, 'be called with', self.expected_args_str,
            other=self.call_args_str, force_disable_repr=True
        )
示例#2
0
    def explanation(self):
        if not self.actual.called:
            return Explanation(
                self.actual, self.is_negative, 'be called once with', self.expected_args_str,
                more_detail='Actually not called', force_disable_repr=True
            )

        additional_info = 'Actually called {call_count} times with Z'.format(call_count=self.actual.call_count)

        return Explanation(
            self.actual, self.is_negative, 'be called once with', self.expected_args_str,
            other=self.call_args_str, more_detail=additional_info, force_disable_repr=True
        )
示例#3
0
    def test_message_of_explanation_with_a_b(self):
        explanation = Explanation(1, False, 'equal', 2)
        expect(explanation.message).to.eq("""
A = 1
B = 2
Expected A to equal B
""")
示例#4
0
 def test_is_repr_with_force_disable_repr(self):
     explanation = Explanation('a',
                               True,
                               'equal',
                               'b',
                               force_disable_repr=True)
     expect(explanation.is_repr).to.eq(False)
示例#5
0
    def test_message_of_explanation_with_a_and_none(self):
        explanation = Explanation(1, False, 'equal', None)
        expect(explanation.message).to.eq("""
A = 1
B = None
Expected A to equal B
""")
示例#6
0
    def test_message_of_explanation_with_another_action(self):
        explanation = Explanation(1, False, 'be within', 0, 'and', 2)
        expect(explanation.message).to.eq("""
A = 1
B = 0
C = 2
Expected A to be within B and C
""")
示例#7
0
 def test_additional_info_with_negative_explanation(self):
     explanation = Explanation(1,
                               True,
                               'called with',
                               2,
                               other=3,
                               more_detail='Some message')
     expect(explanation.more_detail).to.eq('But it happened\n')
示例#8
0
 def test_additional_info_with_pre_defined_more_detail(self):
     explanation = Explanation(1,
                               False,
                               'called with',
                               2,
                               other=3,
                               more_detail='Some message')
     expect(explanation.more_detail).to.eq('Some message\n')
示例#9
0
 def test_another_expected_word_with_none(self):
     explanation = Explanation('func',
                               False,
                               'change',
                               1,
                               another_action='by',
                               another_expected=2,
                               other=None)
     expect(explanation.other_word).to.eq(' Z')
示例#10
0
 def test_other_word(self):
     explanation = Explanation('func',
                               False,
                               'change',
                               1,
                               another_action='by',
                               another_expected=2,
                               other=3)
     expect(explanation.other_word).to.eq(' Z')
示例#11
0
 def explanation(self):
     return Explanation(self.callable.__name__,
                        self.is_negative,
                        'change',
                        self.obj,
                        another_action='by',
                        another_expected=self.amount,
                        other=self.changed,
                        force_disable_repr=True)
示例#12
0
    def explanation(self):
        if self.raised:
            got = self.raised.__class__.__name__
        else:
            got = 'nothing'

        return Explanation(self.expected.__name__,
                           self.is_negative,
                           self.verb,
                           other=got)
示例#13
0
    def test_init(self):
        explanation = Explanation(1,
                                  True,
                                  'within',
                                  2,
                                  'and',
                                  3,
                                  force_disable_repr=True)

        expect(explanation.actual).to.eq(1)
        expect(explanation.is_negative).to.eq(True)
        expect(explanation.action).to.eq('within')
        expect(explanation.expected).to.eq(2)
        expect(explanation.another_expected).to.eq(3)
        expect(explanation.force_disable_repr).to.eq(True)
示例#14
0
    def test_message_of_explanation_with_other(self):
        explanation = Explanation('func',
                                  False,
                                  'change',
                                  1,
                                  another_action='by',
                                  another_expected=2,
                                  other=3,
                                  force_disable_repr=True)
        expect(explanation.message).to.eq("""
A = func
B = 1
C = 2
Z = 3
Expected A to change B by C
Actually change by Z
""")
示例#15
0
    def explanation(self):
        types = [dict, list, str]
        diffs = ['dict_diffs', 'list_diffs', 'str_diffs']
        more_detail = None

        for t, d in zip(types, diffs):
            if type(self.actual) is t and type(self.expected) is t:
                more_detail = getattr(self, d)

        if ordered_dict_available:
            if type(self.actual) in (OrderedDict, dict) and type(
                    self.expected) in (OrderedDict, dict):
                more_detail = self.dict_diffs

        return Explanation(self.actual,
                           self.is_negative,
                           'equal',
                           self.expected,
                           more_detail=more_detail)
示例#16
0
 def explanation(self):
     return Explanation(self.actual, self.is_negative,
                        'be below of or equal to', self.expected)
示例#17
0
 def explanation(self):
     return Explanation(self.actual, self.is_negative, 'be above',
                        self.expected)
示例#18
0
 def test_build_line_with_none(self):
     line = Explanation.build_line(None, 'A', is_repr=True)
     expect(line).to.eq('A = None\n')
示例#19
0
 def explanation(self):
     return Explanation(self.actual, self.is_negative, 'be an instance of',
                        self.expected)
示例#20
0
 def explanation(self):
     return Explanation(self.actual,
                        self.is_negative,
                        'be True',
                        negative_action='be False')
示例#21
0
 def test_expected_word_with_0(self):
     explanation = Explanation(1, False, 0, 'equal')
     expect(explanation.expected_word).to.eq(' B')
示例#22
0
 def explanation(self):
     return Explanation(self.actual, self.is_negative, 'respond to',
                        self.expected)
示例#23
0
 def test_build_line_with_is_repr(self):
     line = Explanation.build_line('a', 'A', is_repr=True)
     expect(line).to.eq("A = 'a'\n")
示例#24
0
 def test_none_expected_word(self):
     explanation = Explanation(1, True, 'be truthy')
     expect(explanation.expected_word).to.eq('')
示例#25
0
 def explanation(self):
     return Explanation(self.actual, self.is_negative, 'be empty')
示例#26
0
 def test_is_passed_called_with_object(self):
     expect(Explanation.is_passed(object)).to.eq(False)
示例#27
0
 def test_is_passed_called_with_none(self):
     expect(Explanation.is_passed(None)).to.eq(True)
示例#28
0
 def explanation(self):
     return Explanation(self.actual, self.is_negative, 'be within',
                        self.expected, 'and', self.args[0])
示例#29
0
文件: regexp.py 项目: tlc28/robber.py
 def explanation(self):
     return Explanation(self.actual, self.is_negative, 'match',
                        self.expected)
示例#30
0
 def test_build_line_with_empty_str(self):
     line = Explanation.build_line('', 'A', is_repr=False)
     expect(line).to.eq('A = \n')
示例#31
0
 def explanation(self):
     return Explanation(self.actual,
                        self.is_negative,
                        'have been ever called with',
                        self.expected_args_str,
                        force_disable_repr=True)
示例#32
0
 def explanation(self):
     return Explanation(self.actual, self.is_negative, 'be called')
示例#33
0
 def test_is_passed_called_with_normal_params(self):
     expect(Explanation.is_passed(1)).to.eq(True)
     expect(Explanation.is_passed('a')).to.eq(True)
示例#34
0
 def explanation(self):
     return Explanation(self.actual, self.is_negative, 'have length of',
                        self.expected)
示例#35
0
 def test_expected_word(self):
     explanation = Explanation(1, True, 'equal', 2)
     expect(explanation.expected_word).to.eq(' B')
示例#36
0
 def explanation(self):
     return Explanation(self.actual,
                        self.is_negative,
                        'be called once',
                        more_detail='Called {0} times'.format(
                            self.actual.call_count))
示例#37
0
 def test_build_line_with_int(self):
     line = Explanation.build_line(1, 'A', is_repr=False)
     expect(line).to.eq('A = 1\n')