Coverage for tests/test_models.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2024-04-28 15:17 +0000

1from typing import TYPE_CHECKING 

2 

3import pytest 

4 

5from prisma.models import User 

6 

7# pyright: reportUnusedClass=false 

8 

9 

10def test_subclass_warn_subclass_argument_deprecated() -> None: 

11 """The class argument `wan_subclass` is deprecated""" 

12 # For some indiscernible reason, this code causes mypy to crash... 

13 # 

14 # The `exclude` option doesn't help us because of the way mypy works it still causes it to crash. 

15 # 

16 # I do not have the time nor the willpower to investigate why this happens so we resort to this solution. 

17 if not TYPE_CHECKING: 

18 with pytest.warns( 

19 DeprecationWarning, 

20 match='The `warn_subclass` argument is deprecated', 

21 ): 

22 

23 class MyUser(User, warn_subclass=False): 

24 pass 

25 

26 with pytest.warns( 

27 DeprecationWarning, 

28 match='The `warn_subclass` argument is deprecated', 

29 ): 

30 

31 class MyUser2(User, warn_subclass=True): 

32 pass