dictation-toolbox / natlink

Natlink provides the interface between Dragon and python
Other
25 stars 17 forks source link

natConnect now returns a context manager. #156

Closed dougransom closed 1 year ago

dougransom commented 1 year ago

natConnect now returns a context manager rather than Nothing. No behavioral changes unless called using the with syntax: now you don't have to worry about disconnecting and whether exceptions happen.

`@pytest.fixture(scope="module") def natlink_connection(monkeymodule): mock_folder=p.WindowsPath(os.path.dirname(file)) / "mock_userdir" monkeymodule.setenv("natlink_userdir",str(mock_folder))

print("\nConnecting natlink")
with n.natConnect():
    yield n.natConnect()  #will be none

`

Implemented with a veneer in init.py.

quintijn commented 1 year ago

I cannot fully understand this one, but if it works, and is more secure, I will merge it in.

quintijn commented 1 year ago

We are planning to change "natlink_userdir" into "natlink_settingsdir" in the next release. This means, that some tests should be changed accordingly.