wimglenn / pytest-structlog

Structured logging assertions
MIT License
54 stars 6 forks source link

Rename fixture to capstructlog #8

Closed MarkusH closed 4 years ago

MarkusH commented 4 years ago

Thank you for this neat library!

The fixture provided by pytest-structlog is named log. That's a very general and unspecific name. I'd like to suggest to rename it to capstructlog following pytest's built-in caplog fixture. Adding backwards compatibility shims shouldn't be an issue.

wimglenn commented 4 years ago

Hello @MarkusH thanks for your kind words.

I don't like the name capstructlog much. I am happy with the existing fixture name, which is short and sweet, it makes tests read nicely e.g. assert log.has("message") or assert event in log.

If any user want to to use a different name, they can do so trivially by adding an alias in their conftest.py file:

# in conftest.py
import pytest_structlog
pytest_structlog.capstructlog = pytest_structlog.log

Then user can use capstructlog as the fixture name everywhere in tests for their project. Since everybody might have their own opinion about the best name, and since it's trivial to rename by user, I'm going to close this issue. Cheers