def test_replace_checks_fields(self): """ Replace will not work if the keyword is incorrect. """ result = Result(None, None, None, None, None) with self.assertRaises(ValueError): result._replace(not_a_field=1)
def test_convert_to_dict(self): """ Can convert to a dictionary. """ result = Result(None, None, None, None, None) self.assertEqual( OrderedDict([('expectation', None), ('actual', None), ('plugin', None), ('stdin', None), ('stdout', None)]), result._asdict())
def test_can_replace(self): """ Can replace values. """ result1 = Result(None, None, None, None, None) result2 = result1._replace(expectation=1, actual=1) self.assertEqual( 'Result(expectation=1, actual=1, plugin=None, ' 'stdin=None, stdout=None)', repr(result2))
def test_convert_to_dict(self): """ Can convert to a dictionary. """ result = Result(None, None, None, None, None) self.assertEqual(OrderedDict([ ('expectation', None), ('actual', None), ('plugin', None), ('stdin', None), ('stdout', None)]), result._asdict())
def test_will_make_from_iterable(self): """ Class method can create new results. """ result = Result._make((None, None, None, None, None)) self.assertEqual( 'Result(expectation=None, actual=None, plugin=None, ' 'stdin=None, stdout=None)', repr(result))
def test_can_copy(self): """ Can copy. """ result1 = Result(None, None, None, None, None) result2 = copy(result1) self.assertTrue(result1 == result2) self.assertFalse(result1 is result2)
def test_requires_correct_args(self): """ TypeError if missing arguments. """ with self.assertRaises(TypeError): Result._make(tuple())