File: test_converters.yml

package info (click to toggle)
python-django-stubs 5.2.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,832 kB
  • sloc: python: 5,185; makefile: 15; sh: 8
file content (36 lines) | stat: -rw-r--r-- 1,098 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
-   case: test_register_converter_builtin
    main: |
      from django.urls import register_converter
      from django.urls.converters import IntConverter

      register_converter(IntConverter, "bigint")

-   case: test_register_converter_custom
    main: |
      from django.urls import register_converter

      class BigIntConverter:
          regex = r"[0-9]+"

          def to_python(self, value: str) -> int:
              return int(value)

          def to_url(self, value: int) -> str:
              return str(value)

      register_converter(BigIntConverter, "bigint")

-   case: test_register_converter_incorrect_types
    main: |
      from django.urls import register_converter

      class BigIntConverter:
          regex = r"[0-9]+"

          def to_python(self, value: int) -> str:
              return str(value)

          def to_url(self, value: str) -> int:
              return int(value)

      register_converter(BigIntConverter, "bigint")  # E: Argument 1 to "register_converter" has incompatible type "type[BigIntConverter]"; expected "type[_Converter]"  [arg-type]