33from labthings .server .view import builder
44
55
6- def test_property_of (app ):
6+ def test_property_of (app , client ):
77 obj = type ("obj" , (object ,), {"property_name" : "propertyValue" })
88
99 GeneratedClass = builder .property_of (obj , "property_name" )
1010 app .add_url_rule ("/" , view_func = GeneratedClass .as_view ("index" ))
1111
12- with app . test_client () as c :
12+ with client as c :
1313 assert c .get ("/" ).data == b"propertyValue"
1414 assert c .post ("/" , data = b"newPropertyValue" ).data == b"newPropertyValue"
1515 assert c .get ("/" ).data == b"newPropertyValue"
1616
1717
18- def test_property_of_dict (app ):
18+ def test_property_of_dict (app , client ):
1919 obj = type (
2020 "obj" ,
2121 (object ,),
@@ -30,7 +30,7 @@ def test_property_of_dict(app):
3030 GeneratedClass = builder .property_of (obj , "properties" )
3131 app .add_url_rule ("/" , view_func = GeneratedClass .as_view ("index" ))
3232
33- with app . test_client () as c :
33+ with client as c :
3434 assert (
3535 c .get ("/" ).data
3636 == b'{"property_name":"propertyValue","property_name_2":"propertyValue2"}\n '
@@ -64,25 +64,25 @@ def test_property_of_name_description():
6464 assert GeneratedClass .__apispec__ .get ("summary" ) == "property description"
6565
6666
67- def test_action_from (app ):
67+ def test_action_from (app , client ):
6868 def f (arg : int , kwarg : str = "default" ):
6969 return {"arg" : arg , "kwarg" : kwarg }
7070
7171 GeneratedClass = builder .action_from (f )
7272 app .add_url_rule ("/" , view_func = GeneratedClass .as_view ("index" ))
7373
74- with app . test_client () as c :
74+ with client as c :
7575 assert c .post ("/" , json = {"arg" : 5 }).data == b'{"arg":5,"kwarg":"default"}\n '
7676
7777
78- def test_action_from_task (app ):
78+ def test_action_from_task (app , client ):
7979 def f (arg : int , kwarg : str = "default" ):
8080 return {"arg" : arg , "kwarg" : kwarg }
8181
8282 GeneratedClass = builder .action_from (f , task = True ,)
8383 app .add_url_rule ("/" , view_func = GeneratedClass .as_view ("index" ))
8484
85- with app . test_client () as c :
85+ with client as c :
8686 response = c .post ("/" , json = {"arg" : 5 }).json
8787 # Check we get back a Task representation
8888 assert isinstance (response , dict )
@@ -103,15 +103,15 @@ def f(arg: int, kwarg: str = "default"):
103103 )
104104
105105
106- def test_static_from (app , app_ctx , static_path ):
106+ def test_static_from (app , client , app_ctx , static_path ):
107107
108108 GeneratedClass = builder .static_from (static_path ,)
109109 app .add_url_rule ("/static" , view_func = GeneratedClass .as_view ("index" ))
110110
111111 with app_ctx .test_request_context ():
112112 assert GeneratedClass ().get ("text" ).status_code == 200
113113
114- with app . test_client () as c :
114+ with client as c :
115115 assert c .get ("/static/text" ).data == b"text"
116116
117117
0 commit comments