コード例 #1
0
ファイル: called_with.py プロジェクト: tlc28/robber.py
    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
ファイル: exception.py プロジェクト: tlc28/robber.py
    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
ファイル: test_explanation.py プロジェクト: vesln/robber.py
 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
ファイル: instanceof.py プロジェクト: tlc28/robber.py
 def explanation(self):
     return Explanation(self.actual, self.is_negative, 'be an instance of',
                        self.expected)
コード例 #20
0
ファイル: boolean.py プロジェクト: tlc28/robber.py
 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
ファイル: test_explanation.py プロジェクト: vesln/robber.py
 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
ファイル: test_explanation.py プロジェクト: vesln/robber.py
 def test_is_passed_called_with_object(self):
     expect(Explanation.is_passed(object)).to.eq(False)
コード例 #27
0
ファイル: test_explanation.py プロジェクト: vesln/robber.py
 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
ファイル: test_explanation.py プロジェクト: vesln/robber.py
 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
ファイル: test_explanation.py プロジェクト: vesln/robber.py
 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
ファイル: called_once.py プロジェクト: tlc28/robber.py
 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
ファイル: test_explanation.py プロジェクト: vesln/robber.py
 def test_build_line_with_int(self):
     line = Explanation.build_line(1, 'A', is_repr=False)
     expect(line).to.eq('A = 1\n')