Skip to content

Use set_log_path hook,but only create log file, nothing in it. #5428

Description

@trimQiu

Using the 'set_log_path' hook on pytest 4.6.2 (Python 3.6.5) creates log files but does not write anything to them.

In conftest.py I write like #4707

@pytest.hookimpl(hookwrapper=True,tryfirst=True)
def pytest_runtest_setup(item):
    config=item.config
    logging_plugin=config.pluginmanager.get_plugin("logging-plugin")
    full_fname=os.path.join("Report",item._request.node.name+".log")
    logging_plugin.set_log_path(full_fname)
    yield

After running the pytest command, there are some log files in the "Report" folder. But size of all log files is 0. My test code is like this:

def test_ok1():
	logging.info("ok1")
	
def test_ok2():
	logging.info("ok2")

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: loggingrelated to the logging builtin plugintype: questiongeneral question, might be closed after 2 weeks of inactivity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions