def it_generates_string_repr_including_types(self): expected = { util.Any(): '<Any>', util.Any(int): '<Any int>', util.Any(int, str): '<Any int, str>', } actual = {instance: repr(instance) for instance in expected} assert expected == actual
def test_it_returns_cursor_pagination_format(self, json): expected = { 'next': util.Optional(util.Any(str)), 'previous': util.Optional(util.Any(str)), 'results': util.Any(list), } actual = json assert expected == actual, 'Response is not in CursorPagination format'
def test_it_returns_limit_offset_pagination_format(self, json): expected = { 'count': util.Any(int), 'next': util.Optional(util.Any(str)), 'previous': util.Optional(util.Any(str)), 'results': util.Any(list), } actual = json assert expected == actual, 'Response is not in LimitOffsetPagination format'
def it_compares_true_to_anything_with_no_args(self): example_values = [ 1, '2', 3.0, b'4', object(), None, True, False, ] any_ = util.Any() inequal_values = [value for value in example_values if any_ != value] assert not inequal_values, \ 'Unexpectedly found values which did not compare true to Any()'
class DescribeAny: def it_compares_true_to_anything_with_no_args(self): example_values = [ 1, '2', 3.0, b'4', object(), None, True, False, ] any_ = util.Any() inequal_values = [value for value in example_values if any_ != value] assert not inequal_values, \ 'Unexpectedly found values which did not compare true to Any()' @pytest.mark.parametrize('expected,actual', [ pytest.param(util.Any(int), 1, id='int'), pytest.param(util.Any(str), '1', id='str'), pytest.param(util.Any(datetime), datetime.today(), id='datetime'), ]) def it_compares_true_to_values_of_same_type(self, expected, actual): assert expected == actual @pytest.mark.parametrize('expected,actual', [ pytest.param(util.Any(int), '1', id='int'), pytest.param(util.Any(str), 1, id='str'), pytest.param(util.Any(datetime), None, id='datetime'), ]) def it_compares_false_to_values_of_other_types(self, expected, actual): assert expected != actual def it_generates_string_repr_including_types(self): expected = { util.Any(): '<Any>', util.Any(int): '<Any int>', util.Any(int, str): '<Any int, str>', } actual = {instance: repr(instance) for instance in expected} assert expected == actual