22
33from  __future__ import  annotations 
44
5+ from  contextlib  import  AbstractContextManager , nullcontext  as  does_not_raise 
56import  json 
6- from  typing  import  TYPE_CHECKING 
7+ from  typing  import  TYPE_CHECKING ,  Any 
78
89from  aiohttp .hdrs  import  METH_PUT 
910from  awesomeversion  import  AwesomeVersion 
1011import  pytest 
1112
13+ from  go2rtc_client .exceptions  import  Go2RtcVersionError 
1214from  go2rtc_client .models  import  WebRTCSdpOffer 
1315from  go2rtc_client .rest  import  _ApplicationClient , _StreamClient , _WebRTCClient 
1416from  tests  import  load_fixture 
@@ -94,22 +96,25 @@ async def test_streams_add(
9496    responses .assert_called_once_with (url , method = METH_PUT , params = params )
9597
9698
99+ VERSION_ERR  =  "server version '{}' not >= 1.9.5 and < 2.0.0" 
100+ 
101+ 
97102@pytest .mark .parametrize ( 
98103    ("server_version" , "expected_result" ), 
99104    [ 
100-         ("0.0.0" , False ), 
101-         ("1.9.4" , False ), 
102-         ("1.9.5" , True ), 
103-         ("1.9.6" , True ), 
104-         ("2.0.0" , False ), 
105-         ("BLAH" , False ), 
105+         ("0.0.0" , pytest . raises ( Go2RtcVersionError ,  match = VERSION_ERR . format ( "0.0.0" )) ), 
106+         ("1.9.4" , pytest . raises ( Go2RtcVersionError ,  match = VERSION_ERR . format ( "1.9.4" )) ), 
107+         ("1.9.5" , does_not_raise () ), 
108+         ("1.9.6" , does_not_raise () ), 
109+         ("2.0.0" , pytest . raises ( Go2RtcVersionError ,  match = VERSION_ERR . format ( "2.0.0" )) ), 
110+         ("BLAH" , pytest . raises ( Go2RtcVersionError ,  match = VERSION_ERR . format ( "BLAH" )) ), 
106111    ], 
107112) 
108113async  def  test_version_supported (
109114    responses : aioresponses ,
110115    rest_client : Go2RtcRestClient ,
111116    server_version : str ,
112-     expected_result : bool ,
117+     expected_result : AbstractContextManager [ Any ] ,
113118) ->  None :
114119    """Test webrtc offer.""" 
115120    payload  =  json .loads (load_fixture ("application_info_answer.json" ))
@@ -119,7 +124,8 @@ async def test_version_supported(
119124        status = 200 ,
120125        payload = payload ,
121126    )
122-     assert  await  rest_client .validate_server_version () ==  expected_result 
127+     with  expected_result :
128+         await  rest_client .validate_server_version ()
123129
124130
125131async  def  test_webrtc_offer (
0 commit comments