Coverage for tests/test_typing_warnings.py: 100%

29 statements  

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

1import pytest 

2 

3from prisma import Prisma 

4 

5 

6@pytest.mark.asyncio 

7async def test_warn_when_connect_timeout_is_int() -> None: 

8 """Ensure that `calling Prisma(connect_timeout:int)` emit a warning 

9 

10 https://github.com/RobertCraigie/prisma-client-py/issues/167 

11 """ 

12 with pytest.warns(DeprecationWarning): 

13 Prisma(connect_timeout=10) 

14 

15 

16@pytest.mark.asyncio 

17async def test_warn_when_calling_connect_with_int_timeout() -> None: 

18 """Ensure that calling `client.connect(timeout:int)` emit a warning 

19 

20 https://github.com/RobertCraigie/prisma-client-py/issues/167 

21 """ 

22 client = Prisma() 

23 with pytest.warns(DeprecationWarning): 

24 await client.connect(timeout=10) 

25 

26 

27@pytest.mark.asyncio 

28async def test_warn_when_calling_disconnect_with_float_timeout() -> None: 

29 """Ensure that calling `client.disconnect(timeout:float)` emit a warning 

30 

31 https://github.com/RobertCraigie/prisma-client-py/issues/167 

32 """ 

33 client = Prisma() 

34 await client.connect() 

35 with pytest.warns(DeprecationWarning): 

36 await client.disconnect(timeout=5.0) 

37 

38 

39@pytest.mark.asyncio 

40async def test_warn_when_calling_tx_with_int_max_wait() -> None: 

41 """Ensure that calling `client.tx(max_wait:int)` emit a warning 

42 

43 https://github.com/RobertCraigie/prisma-client-py/issues/167 

44 """ 

45 client = Prisma() 

46 await client.connect() 

47 with pytest.warns(DeprecationWarning): 

48 client.tx(max_wait=2000) 

49 

50 

51@pytest.mark.asyncio 

52async def test_warn_when_calling_tx_with_int_timeout() -> None: 

53 """Ensure that calling `client.tx(timeout:int)` emit a warning 

54 

55 https://github.com/RobertCraigie/prisma-client-py/issues/167 

56 """ 

57 client = Prisma() 

58 await client.connect() 

59 with pytest.warns(DeprecationWarning): 

60 client.tx(timeout=5000)