-
Notifications
You must be signed in to change notification settings - Fork 0
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
Remove logging from tests #8
Comments
Let's hear what @The-Compiler has to say, but just to point out we could install pytest-capturelog too. |
Qt uses qWarning a lot internally when something is wrong, where Python probably would use exceptions instead - and in qutebrowser, there are some places where I log an error and recover on recoverable exceptions. Currently those are printed as "LOG WARNING ..." for example, and qutebrowser's buildbot notices that pattern and shows "warnings" instead of "success" (example / stdio). I think capturelog would be cool for the debug logs, but ideally also tests would show that output (or fail entirely, that works as well), when there's any logging output with level warnings or higher which isn't in a |
@nicoddemus Do you think we can imitate the current behaviour with pytest-capturelog ❓ |
Not directly, because as @The-Compiler mentioned Qt has its own logging system. I will see the specific uses in the code base, but it seems like the ideal solution would be to implement functionality similar to |
Should we close this one? 😶 |
I think the current solution using pytest-capturelog is good enough... @The-Compiler, thoughts? |
Hmm, it doesn't seem to work properly so far. I'd like log outputs in the format The change I did to get logging: diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py
index b866420..98b7678 100644
--- a/qutebrowser/utils/utils.py
+++ b/qutebrowser/utils/utils.py
@@ -29,7 +29,7 @@ import functools
import contextlib
import itertools
-from PyQt5.QtCore import Qt
+from PyQt5.QtCore import Qt, qWarning
from PyQt5.QtGui import QKeySequence, QColor
import pkg_resources
@@ -39,6 +39,8 @@ from qutebrowser.utils import qtutils, log
def elide(text, length):
"""Elide text so it uses a maximum of length chars."""
+ qWarning("warning")
+ log.misc.error("log")
if length < 1:
raise ValueError("length must be >= 1!")
if len(text) <= length: The output:
I really don't get what's happening there... why do I get the logging output while collecting the tests? |
Hmm is |
It seems it's called when importing stuff (as there's debug logging going on):
So let's not worry about that - but why doesn't |
My guess is that it only displays the logging output if a test fails, which is the same behavior exhibited by pytest regarding stdout/stderr capture. |
Oh, right. I considered opening a PR against pytest-capturelog to add something like a Maybe that's a good reason to switch to pytest-catchlog then. In the latest commit they even mention:
I'll open an issue there to see if using separate levels for that would be a welcome addition and if it's active. Then the other missing bit would be a message handler for pytest-qt so it uses logging - |
Oh, that might be the reason of why it was forked then. About logging for pytest-qt, I was thinking to provide a separate fixture similar to
Were you thing along the same lines? |
Finally closing this one 😉 |
😤 👍 |
Should we keep the logging in the tests? Is it strictly necessary?
https://github.com/hackebrot/qutebrowser/blob/master/qutebrowser/test/log.py
@The-Compiler can you please briefly explain your thoughts behind the named module? Am I right that it is only used in the QApplication of the tests?
The text was updated successfully, but these errors were encountered: