Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update testutils.py #423

Open
wants to merge 1 commit into
base: naomi-dev
Choose a base branch
from
Open

Conversation

YadlaMani
Copy link

Implementing try-catch error handling to enhance code clarity and reduce errors.

@CLAassistant
Copy link

CLAassistant commented Oct 7, 2024

CLA assistant check
All committers have signed the CLA.

@aaronchantrill aaronchantrill self-requested a review October 8, 2024 13:42
Copy link
Contributor

@aaronchantrill aaronchantrill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are with regard to the naomi/testutils.py module, which is used by various test programs within Naomi to perform unit tests. These should be initiated through the unittest package by a command like python -m unittest discover.

These changes look well thought out, although I'm not aware of any current issues that require them. Additionally, the reason most of these exceptions pass quietly rather than raising a warning or error is that they are only required if the test itself is going to be called.

For instance, the TEST_PROFILE['google'] entry is only required if the user has the google-stt plugin running, which requires that the user manually install the google.cloud package. If the user has not installed this package, the plugin will be skipped automatically, and the TEST_PROFILE['google'] variable will not be used. I'm afraid that in these cases, raising a warning is more likely to confuse users who may think they need that key. The idea behind leaking some real values into the test profile was to catch errors caused by API changes in cloud services that would not be caught using mock.

It would probably make sense to pull these values into the test profile from the live profile in the init method of the actual unit test, rather than when generating the test profile.

With regard to the wait_for_keyword() method, you are correct that the first parameter should be cls rather than self, although since this is not used it might be better to define the whole thing as a static method. I'm not sure under what circumstances a return statement would fail and trigger the exception.

What would be super helpful would be to be able to run tests in the ~/.config/naomi directory in addition to the main Naomi directory structure.

It's going to take a little while for me to digest these changes and make sure they actually do what we want them to do, so please be patient with me while I review them. In the meantime, if you could create an issue and describe your reasons for the changes in more detail, that would be greatly appreciated.

Thank you,
Aaron

@aaronchantrill
Copy link
Contributor

@YadlaMani - Testing these changes requires introducing issues into other modules and observing the results to make sure no issues are being masked by the try/except handling. It's a time consuming process and I'm not sure I'm going to have the energy to finish it before the end of October. I also haven't seen any issues requesting changes to the unit testing process. If you ran into issues because of this file, then please let me know, but I'm inclined to reject these changes. We do have issue 347 - #347 which you could use to get four pull requests pretty quickly if you are interested. Please get in touch. Thank you, Aaron

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants