Skip to content
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

Implement WriteLogger #403

Merged
merged 10 commits into from
Mar 16, 2022
Merged

Implement WriteLogger #403

merged 10 commits into from
Mar 16, 2022

Conversation

Tinche
Copy link
Contributor

@Tinche Tinche commented Mar 12, 2022

The WriteLogger.

Let me know if this is good and I can add some docs.

@hynek
Copy link
Owner

hynek commented Mar 12, 2022

Please don’t do this unittest thing of subclassing.

I don’t see anything speaking against a fixture that yields first one type and than the other? You should be even able to pass instances if I see it correctly on my phone.

@Tinche
Copy link
Contributor Author

Tinche commented Mar 12, 2022

I hate the unittest style but it was already being used. I got the subclassing approach from the stdlib :p

How bout I just refactor this into bare functions and parametrize the class with pytest?

@hynek
Copy link
Owner

hynek commented Mar 12, 2022

I hate the unittest style but it was already being used. I got the subclassing approach from the stdlib :p

Yes that’s where I learned to hate it. ;)

How bout I just refactor this into bare functions and parametrize the class with pytest?

💗💗💗

i mean leave the class to group them, otherwise the function names get a bit long?

@Tinche
Copy link
Contributor Author

Tinche commented Mar 13, 2022

Alright, done!

@hynek
Copy link
Owner

hynek commented Mar 13, 2022

You can simplify this by using a fixture:

@pytest.fixture(name="logger_cls", params=(WriteLogger, PrintLogger))
def _logger_cls(request):
    return request.param

@Tinche
Copy link
Contributor Author

Tinche commented Mar 13, 2022

Alright, done.

tests/test_loggers.py Outdated Show resolved Hide resolved
src/structlog/_loggers.py Outdated Show resolved Hide resolved
src/structlog/_loggers.py Outdated Show resolved Hide resolved
src/structlog/_loggers.py Outdated Show resolved Hide resolved
class TestPrintLogger:
def test_prints_to_stdout_by_default(self, capsys):
class TestLoggers:
"""Tests common to the Print and WriteLoggers."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Tests common to the Print and WriteLoggers."""
"""
Tests common to the Print and WriteLoggers.
"""

@hynek
Copy link
Owner

hynek commented Mar 15, 2022

There's a bunch of unused imports – pls fix that and we're done here.

@Tinche
Copy link
Contributor Author

Tinche commented Mar 15, 2022

Yessir

@hynek hynek merged commit e20ca64 into hynek:main Mar 16, 2022
@hynek
Copy link
Owner

hynek commented Mar 16, 2022

thankssss

@Tinche
Copy link
Contributor Author

Tinche commented Mar 16, 2022

<3

@Tinche Tinche deleted the tin/writelogger branch March 16, 2022 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants