(api_client, device_simulator)
| 118 | |
| 119 | |
| 120 | def _attach(api_client, device_simulator): |
| 121 | # Tests re-attach after loading a second project; drop any live connection |
| 122 | # first (io.connect errors when already connected) and give the simulator's |
| 123 | # watcher thread time to clear the dead client socket before reconnecting. |
| 124 | try: |
| 125 | api_client.disconnect_device() |
| 126 | time.sleep(0.6) |
| 127 | except Exception: |
| 128 | pass |
| 129 | api_client.configure_network(host="127.0.0.1", port=9000, socket_type="tcp") |
| 130 | time.sleep(0.1) |
| 131 | api_client.set_operation_mode("project") |
| 132 | try: |
| 133 | api_client.command("project.activate") |
| 134 | except Exception: |
| 135 | pass |
| 136 | time.sleep(0.2) |
| 137 | api_client.connect_device() |
| 138 | assert device_simulator.wait_for_connection(timeout=5.0) |
| 139 | |
| 140 | |
| 141 | def _reg(api_client, name): |
no test coverage detected