diff --git a/skillbridge/client/channel.py b/skillbridge/client/channel.py index 5400647..2a7525f 100644 --- a/skillbridge/client/channel.py +++ b/skillbridge/client/channel.py @@ -167,7 +167,7 @@ def try_repair(self) -> Exception | str: def close(self) -> None: if self.connected: - self.socket.sendall(b' 5close') + self.socket.sendall(b' 5$close') self.socket.close() self.connected = False diff --git a/skillbridge/client/workspace.py b/skillbridge/client/workspace.py index 53ca54c..d5fc44d 100644 --- a/skillbridge/client/workspace.py +++ b/skillbridge/client/workspace.py @@ -37,15 +37,6 @@ def __getattr__(self, item: Any) -> NoReturn: current_workspace = _no_workspace -def _register_well_known_functions(ws: Workspace) -> None: - @ws.register - def db_check(d_cellview: Any) -> None: - """ - Checks the integrity of the database. - """ - _ = d_cellview - - _unbound = Symbol('unbound') @@ -201,8 +192,6 @@ def __init__( self.user = FunctionCollection(channel, 'user', self._translator) - _register_well_known_functions(self) - def _prepare_default_translator(self) -> DefaultTranslator: translator = DefaultTranslator() types = [('Remote', RemoteObject), ('Table', RemoteTable), ('Vector', RemoteVector)] diff --git a/skillbridge/server/python_server.py b/skillbridge/server/python_server.py index ff9489c..102fc25 100644 --- a/skillbridge/server/python_server.py +++ b/skillbridge/server/python_server.py @@ -125,7 +125,7 @@ def handle_one_request(self) -> bool: logger.debug(f"received {len(command)} bytes") - if command.startswith(b'close'): + if command.startswith(b'$close'): logger.debug(f"client {self.client_address} disconnected") return False logger.debug(f"got data {command[:1000].decode()}") diff --git a/tests/test_integration.py b/tests/test_integration.py index d28992f..73eba3b 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -2,7 +2,7 @@ from time import sleep from warnings import warn -from pytest import fixture, raises, skip +from pytest import fixture, mark, raises, skip from skillbridge import LazyList, RemoteObject, RemoteTable, SkillCode, Symbol, Var, Workspace @@ -236,11 +236,32 @@ def test_run_script_blocks_when_requested(ws: Workspace) -> None: assert ws['plus'](Var(variable), 1) == 43 +@mark.skip def test_form_vectors_have_dir(ws: Workspace) -> None: form = ws.hi.get_current_form() assert 'button_layout' in dir(form) +@mark.skip def test_form_vectors_have_getattr(ws: Workspace) -> None: form = ws.hi.get_current_form() assert isinstance(form.button_layout, list) + + +def test_outstring(ws: Workspace) -> None: + outstring = ws['outstring'] + get_outstring = ws['getOutstring'] + close = ws['close'] + fprintf = ws['fprintf'] + + s = outstring() + assert get_outstring(s) == "" # noqa: PLC1901 + + assert fprintf(s, "Hello ") + assert get_outstring(s) == "Hello " + + assert fprintf(s, "World") + assert get_outstring(s) == "Hello World" + + assert close(s) + assert get_outstring(s) is None