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
Quiet Mode should not generate any output #830
Conversation
Codecov Report
@@ Coverage Diff @@
## master #830 +/- ##
==========================================
+ Coverage 83.37% 88.58% +5.21%
==========================================
Files 156 156
Lines 2574 2585 +11
Branches 277 280 +3
==========================================
+ Hits 2146 2290 +144
+ Misses 360 231 -129
+ Partials 68 64 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As well as the comments, could you add a quiet mode test (or tests per section) to show that these work, since I'm guessing we weren't triggering a fail correctly before?
[Panel(f"[yellow]{cve.cve_number}[/yellow]") for cve in cves] | ||
), | ||
) | ||
if self.error_mode.value > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good, but I'd like some comments in here to mention quiet mode to explain why these are like this, mostly so it's there as a reminder for folk adding any further output.
): | ||
total_tasks = len(tasks) | ||
|
||
if self.error_mode.value > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also mention quiet mode here.
@@ -310,7 +316,12 @@ def populate_db(self): | |||
""" | |||
del_cve_range = "DELETE from cve_range where CVE_number=?" | |||
|
|||
for year in track(self.nvd_years(), description="Updating CVEs from NVD..."): | |||
if self.error_mode.value > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here
@terriko, here problem is we are asserting logger shouldn't produce any output in quiet mode but we are supposed to assert there should be no output produced on console in quiet mode. This isn't very hard to do if we just use unittest or pytest but we are using pytest to run unittest which is making things more complicated. I recommend switching to pytest in this case because it provides easy way to capture stdout and stderr. |
I think we talked about this yesterday, but just to confirm: I agree that switching to pytest and updating the quiet mode test sounds like the correct solution. |
|
||
# Make sure log is empty | ||
assert not caplog.records | ||
|
||
# Make sure nothing is getting printed on stdout or stderr | ||
captured = capsys.readouterr() | ||
assert not (captured.out or captured.err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated tests for quiet mode.
CI is failing due to following error: > assert not (captured.out or captured.err)
E assert not ('' or "warning: no files found matching 'test/binaries/*.c'\n")
E + where '' = CaptureResult(out='', err="warning: no files found matching 'test/binaries/*.c'\n").out
E + and "warning: no files found matching 'test/binaries/*.c'\n" = CaptureResult(out='', err="warning: no files found matching 'test/binaries/*.c'\n").err I am not sure from where this warning is being generated. I am not facing any errors locally. |
04816a3
to
1412ff7
Compare
I found out the bug. In egg_updater I have just redirected stdout and I forget to redirect stderr which was producing warning sometimes. At least we can be sure that new quiet mode test is working correctly. |
f0623e1
to
b1d583f
Compare
5814ec8
to
fa769a2
Compare
Depends on #851