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

refactor(tests): add logging output to console and deal with DEBUG mode #358

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sdenef-adeo
Copy link
Contributor

When testing, I would like my IDE to output logs to the console.
And I would like to set DEBUG mode like we do for running code.

I'm not this is the best way to do. And how to avoid duplicated code, already existing in utils.setup_logging() function.
Feel free to improve my code.

@lvaylet
Copy link
Collaborator

lvaylet commented Nov 3, 2023

Hi @sdenef-adeo, which IDE do you use? Using DEBUG mode should be as simple as setting the DEBUG env variable to 1. This can be done in multiple ways. For example with a .env file that is automatically picked up by the IDE or the test engine. Or by setting the env variable explicitly during tests.

@sdenef-adeo
Copy link
Contributor Author

Hi @lvaylet ,

Did you try?

I use Intellij IDEA.
Here are the ouputs for the same launch configuration (DEBUG=1)

Against master branch:
slo-generator_test_against_master

Against my PR branch:
slo-generator_test_against_pr-branch

AFAIU the DEBUG is never read when running tests as it does not reach utils.setup_logging() nor constants.DEBUG

@lvaylet
Copy link
Collaborator

lvaylet commented Nov 17, 2023

Got it. I assumed "testing" meant "running slo-generator compute ... manually in my terminal". Not "unit testing". So yes, this does make sense.

Let me take a look and see how we can leverage the existing utils.setup_logging().

@lvaylet
Copy link
Collaborator

lvaylet commented Nov 17, 2023

Is there a specific reason why you decided not to call utils.setup_logging()?

We could rewrite it so it remains compatible with the current usage (for example by adding options with default values) and let you use debug mode in unit tests at the same time.

@sdenef-adeo
Copy link
Contributor Author

Is there a specific reason why you decided not to call utils.setup_logging()?

Hello,

No reason except I'm not familiar with Python logging. ;)

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