-
-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
co-authored-by: Nikita Sobolev <[email protected]>
- Loading branch information
1 parent
9880684
commit 3f74251
Showing
2 changed files
with
48 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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] |