-
Notifications
You must be signed in to change notification settings - Fork 5
Merging into pytest-catchlog? #1
Comments
Let me say upfront that I have no problems merging the projects, however, we have at least two issues:
Would you be interested in merging both plugins but under If the answer to both the above questions is no, I'm sure we can still work something out but I'll need to bring this matter to SaltStack to get permission to release my work under the MIT license. |
There actually was some discussion on the pytest-dev mailinglist to rename We're discussing about moving I've not tried In the end, those are questions which @eisensheng and @abusalimov will need to answer. I guess the rename will cause some confusion as well, but I guess less than having three logging pluggins 😉 I'm fine with both Note |
Well, pytest-logging displays logging messages to the console, period. Ie, there's no logic involved on showing or not the log messages if the test fails or not. The only logic involved is setting the log level on a The first time I wrote this logging code was on a project which was using py.test to run it's tests and we needed some background logs to see what was going on(not necessarily when a test failed). I then needed to work on a pytest plugin which needs to do some boilerplate work before actually running any tests and I ended up adding the same code to it.
I'll wait for the replies of all the @ "tagged" users... |
Does it? Just tried it on one of my projects: it does not display logs unless a test case fails. And when it fails, the log output is just mixed into Comparing to pytest-catchlog, what additional features does this plugin provide? I mean what exactly could I achieve with pytest-logging, but not using pytest-catchlog. I can see |
Oh, yeah, I forgot to mention, you need to disable pytest output capturing, |
Unless there's a better way of showing the logs without disabling pytest output capturing? I'm pretty new to pytest, and let's not talk about pytest internals.... |
Ah, I see... Didn't know about the In pytest-catchlog we use slightly different approach, and add a separate "captured log" output section, which involves capturing, obviously. I'm not sure whether is possible to make it work nice with |
I imagine there should not be any troubles since you use your own handler to take care of capturing... |
That sounds pretty much like the default behaviour of @s0undt3ch - if we don't get to a conclusion about merging, would you consider renaming I hope this doesn't sound offending - sorry if it does, that's not my intention. 😄 |
And |
Honestly, I also prefer merging the plugins and I just asked for guidance from SaltStack regarding this subject. Regarding your line, "That sounds pretty much like the default behaviour of logging/pytest - logging logs to stderr, and pytest displays that when you run it with -s.", are you saying that pytest already does this? Because it didn't the first time I wrote this code... Or are you saying that its the default behavior of logging and pytest on it's own? |
Try running this without a plugin and with import logging
import time
def test_foo():
logging.error("foo")
time.sleep(1)
logging.error("bar") If you want another loglevel, you'd need to set the loglevel, e.g. using a autouse fixture: import logging
import time
import pytest
@pytest.fixture(autouse=True)
def set_loglevel():
logging.basicConfig(level=logging.DEBUG)
def test_foo():
logging.debug("foo")
time.sleep(1)
logging.debug("bar") So unless I misunderstood something (if so, please let me know!), But I'd say let's wait for @eisensheng's opinion on this. |
You're almost right. The default behavior is to redirect logs of level Basically, the following lines would be enough to output everything: import logging
def pytest_configure():
logging.basicConfig(level=logging.NOTSET) # or whatever level you prefer |
Ok, so, it seems that my plugin only adds the log level tweak feature at the CLI level... (guess I forgot my original findings on the matter) |
Sorry, wrong. On top of |
For now, I'm "occupying" the pytest-logging name, however, I'm leaning towards contributing what my plugin does into |
Ok, I've got the 👍 from SaltStack. I'll be creating a PR against catchlog soon to implement eisensheng/pytest-catchlog#14. ... under MIT, so even less trouble. |
Perhaps a better name for this library, given this discussion, is |
There's no reason why you should use this plugin anymore. |
Hey,
there's unfortunately already some confusion around pytest logging plugins, as there's the abandoned pytest-capturelog and the maintained pytest-catchlog fork. Unfortunately, having another
pytest-logging
plugin only increases that confusion 😉What are your thoughts about merging the functionality of
pytest-logging
intopytest-catchlog
? It already has--log-format
and--log-date-format
arguments, so I guess only the-v
handling is what's missing from it?/cc @hpk42 @eisensheng @abusalimov
The text was updated successfully, but these errors were encountered: