import unittest
import time
from saleae import automation
def main():
logic_2 = automation.Manager.launch()
time.sleep(10)
logic_2.close()
class TestLogicLaunch(unittest.TestCase):
def test_logic_launch(self):
logic_2 = automation.Manager.launch()
time.sleep(10)
logic_2.close()
if __name__ == '__main__':
main()
I have simplified my code to the simplest version to demonstrate the problem. In the code above, when I run the program from the terminal, thus just executing the main function, the program executes without error, producing the result:
INFO:saleae.automation.manager:sub ChannelConnectivity.IDLE
INFO:saleae.automation.manager:sub ChannelConnectivity.CONNECTING
INFO:saleae.automation.manager:sub ChannelConnectivity.TRANSIENT_FAILURE
INFO:saleae.automation.manager:sub ChannelConnectivity.READY
However, when I run the same code in a test case(as the test_logic_launch function, using vscode’s testcase runner) the automation.Manager.launch() function fails to execute producing the following error:
test_logic_launch (Logic2_launch_test.TestLogicLaunch) ... ERROR
NoneType: None
======================================================================
ERROR: test_logic_launch (Logic2_launch_test.TestLogicLaunch)
----------------------------------------------------------------------
Traceback (most recent call last):
File "c:\Users\jmansky\Desktop\Logic2_launch_test.py", line 13, in test_logic_launch
logic_2 = automation.Manager.launch()
File "C:\Users\jmansky\AppData\Local\Programs\Python\Python39-32\lib\site-packages\saleae\automation\manager.py", line 384, in launch
return cls(
File "C:\Users\jmansky\AppData\Local\Programs\Python\Python39-32\lib\site-packages\saleae\automation\manager.py", line 310, in __init__
raise exc from None
File "C:\Users\jmansky\AppData\Local\Programs\Python\Python39-32\lib\site-packages\saleae\automation\manager.py", line 290, in __init__
app_info = self.get_app_info()
File "C:\Users\jmansky\AppData\Local\Programs\Python\Python39-32\lib\site-packages\saleae\automation\manager.py", line 417, in get_app_info
reply: saleae_pb2.GetAppInfoReply = self.stub.GetAppInfo(saleae_pb2.GetAppInfoRequest())
File "C:\Users\jmansky\AppData\Local\Programs\Python\Python39-32\lib\site-packages\grpc\_channel.py", line 1030, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "C:\Users\jmansky\AppData\Local\Programs\Python\Python39-32\lib\site-packages\grpc\_channel.py", line 910, in _end_unary_response_blocking
raise _InactiveRpcError(state) # pytype: disable=not-instantiable
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses; last error: UNAVAILABLE: ipv4:127.0.0.1:10430: WSA Error"
debug_error_string = "UNKNOWN:failed to connect to all addresses; last error: UNAVAILABLE: ipv4:127.0.0.1:10430: WSA Error {created_time:"2023-06-09T15:20:54.490186608+00:00", grpc_status:14}"
>
----------------------------------------------------------------------
Ran 1 test in 21.201s
FAILED (errors=1)
I do not understand why running the launch function inside of unittest would cause this error to occur. Any help or potential solutions would be greatly appreciated.