11import logging
22import inspect
33import time
4- from copy import deepcopy
54from typing import Callable , Any , Type , Tuple , Iterator , Iterable , Union
65
76import sanic
1716import pyalect .builtins .pytest # noqa
1817
1918import idom
20- from idom .client .manage import (
21- build_config ,
22- build as build_client ,
23- restore as restore_client ,
24- )
19+ from idom .client import manage as manage_client
2520from idom .core import ElementConstructor , AbstractElement
2621from idom .server .prefab import hotswap_server , AbstractRenderServer
2722from idom .server .utils import find_available_port
@@ -272,31 +267,6 @@ def _clean_last_server_error(last_server_error) -> Iterator[None]:
272267 yield
273268
274269
275- @pytest .fixture
276- def install ():
277- def add_dependency (* packages ):
278- config = build_config ()
279- with config .change_entry ("tests" ) as entry :
280- old_js_deps = entry .setdefault ("js_dependencies" , [])
281- new_js_deps = set (packages ).union (old_js_deps )
282- entry ["js_dependencies" ] = list (new_js_deps )
283- if old_js_deps != new_js_deps :
284- build_client ()
285-
286- return add_dependency
287-
288-
289- @pytest .fixture
290- def temp_build_config ():
291- config = build_config ()
292- original_cfgs = [deepcopy (cfg ) for cfg in config .data ["entries" ].values ()]
293- try :
294- yield config
295- finally :
296- config .update_entries (original_cfgs )
297- config .save ()
298-
299-
300270@pytest .fixture (scope = "session" , autouse = True )
301271def _restore_client (pytestconfig : Config ) -> Iterator [None ]:
302272 """Restore the client's state before and after testing
@@ -306,8 +276,8 @@ def _restore_client(pytestconfig: Config) -> Iterator[None]:
306276 after testing and may effect usage of IDOM beyond the scope of the tests.
307277 """
308278 if pytestconfig .option .restore_client :
309- restore_client ()
279+ manage_client . restore ()
310280 yield
311- restore_client ()
281+ manage_client . restore ()
312282 else :
313283 yield
0 commit comments