MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / test_invalid_input

Method test_invalid_input

tests/test_codecs.py:733–835  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

731 ''')
732
733 async def test_invalid_input(self):
734 # The latter message appears beginning in Python 3.10.
735 integer_required = (
736 r"(an integer is required|"
737 r"\('str' object cannot be interpreted as an integer\))")
738
739 cases = [
740 ('bytea', 'a bytes-like object is required', [
741 1,
742 'aaa'
743 ]),
744 ('bool', 'a boolean is required', [
745 1,
746 ]),
747 ('int2', integer_required, [
748 '2',
749 'aa',
750 ]),
751 ('smallint', 'value out of int16 range', [
752 2**256, # check for the same exception for any big numbers
753 decimal.Decimal("2000000000000000000000000000000"),
754 0xffff,
755 0xffffffff,
756 32768,
757 -32769
758 ]),
759 ('float4', 'value out of float32 range', [
760 4.1 * 10 ** 40,
761 -4.1 * 10 ** 40,
762 ]),
763 ('int4', integer_required, [
764 '2',
765 'aa',
766 ]),
767 ('int', 'value out of int32 range', [
768 2**256, # check for the same exception for any big numbers
769 decimal.Decimal("2000000000000000000000000000000"),
770 0xffffffff,
771 2**31,
772 -2**31 - 1,
773 ]),
774 ('int8', integer_required, [
775 '2',
776 'aa',
777 ]),
778 ('bigint', 'value out of int64 range', [
779 2**256, # check for the same exception for any big numbers
780 decimal.Decimal("2000000000000000000000000000000"),
781 0xffffffffffffffff,
782 2**63,
783 -2**63 - 1,
784 ]),
785 ('text', 'expected str, got bytes', [
786 b'foo'
787 ]),
788 ('text', 'expected str, got list', [
789 [1]
790 ]),

Callers

nothing calls this directly

Calls 2

prepareMethod · 0.45
fetchvalMethod · 0.45

Tested by

no test coverage detected