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 )
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 )
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 """)
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)
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 """)
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 """)
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')
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')
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')
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')
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)
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)
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)
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 """)
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)
def explanation(self): return Explanation(self.actual, self.is_negative, 'be below of or equal to', self.expected)
def explanation(self): return Explanation(self.actual, self.is_negative, 'be above', self.expected)
def test_build_line_with_none(self): line = Explanation.build_line(None, 'A', is_repr=True) expect(line).to.eq('A = None\n')
def explanation(self): return Explanation(self.actual, self.is_negative, 'be an instance of', self.expected)
def explanation(self): return Explanation(self.actual, self.is_negative, 'be True', negative_action='be False')
def test_expected_word_with_0(self): explanation = Explanation(1, False, 0, 'equal') expect(explanation.expected_word).to.eq(' B')
def explanation(self): return Explanation(self.actual, self.is_negative, 'respond to', self.expected)
def test_build_line_with_is_repr(self): line = Explanation.build_line('a', 'A', is_repr=True) expect(line).to.eq("A = 'a'\n")
def test_none_expected_word(self): explanation = Explanation(1, True, 'be truthy') expect(explanation.expected_word).to.eq('')
def explanation(self): return Explanation(self.actual, self.is_negative, 'be empty')
def test_is_passed_called_with_object(self): expect(Explanation.is_passed(object)).to.eq(False)
def test_is_passed_called_with_none(self): expect(Explanation.is_passed(None)).to.eq(True)
def explanation(self): return Explanation(self.actual, self.is_negative, 'be within', self.expected, 'and', self.args[0])
def explanation(self): return Explanation(self.actual, self.is_negative, 'match', self.expected)
def test_build_line_with_empty_str(self): line = Explanation.build_line('', 'A', is_repr=False) expect(line).to.eq('A = \n')
def explanation(self): return Explanation(self.actual, self.is_negative, 'have been ever called with', self.expected_args_str, force_disable_repr=True)
def explanation(self): return Explanation(self.actual, self.is_negative, 'be called')
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)
def explanation(self): return Explanation(self.actual, self.is_negative, 'have length of', self.expected)
def test_expected_word(self): explanation = Explanation(1, True, 'equal', 2) expect(explanation.expected_word).to.eq(' B')
def explanation(self): return Explanation(self.actual, self.is_negative, 'be called once', more_detail='Called {0} times'.format( self.actual.call_count))
def test_build_line_with_int(self): line = Explanation.build_line(1, 'A', is_repr=False) expect(line).to.eq('A = 1\n')