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

Test false utc formatting #662

Conversation

python-mutation-testing

Summary

This is a test case to test the functionality of MaybeTimeStamper in cases where the UTC argument is false and the formatting is affected by that.
This closes #661.

Pull Request Check List

  • Do not open pull requests from your main branch – use a separate branch!
    • There's a ton of footguns waiting if you don't heed this warning. You can still go back to your project, create a branch from your main branch, push it, and open the pull request from the new branch.
    • This is not a pre-requisite for your pull request to be accepted, but you have been warned.
  • Added tests for changed code.
    • The CI fails with less than 100% coverage.
  • New APIs are added to our typing tests in api.py.
  • Updated documentation for changed code.
    • New functions/classes have to be added to docs/api.rst by hand.
    • Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives.
      • The next version is the second number in the current release + 1. The first number represents the current year. So if the current version on PyPI is 23.1.0, the next version is gonna be 23.2.0. If the next version is the first in the new year, it'll be 24.1.0.
  • Documentation in .rst and .md files is written using semantic newlines.
  • Changes (and possible deprecations) are documented in the changelog.
  • Consider granting push permissions to the PR branch, so maintainers can fix minor issues themselves without pestering you.

@hynek
Copy link
Owner

hynek commented Oct 24, 2024

I'm sorry if this is not the case, but this looks like AI slop to me. Especially due to the changelog change, but also it doesn't test what it claims to test at all. Finally, the utc flag is in fact tested for the class that is actually formatting:

@freeze_time("1980-03-25 16:00:00")
def test_local(self):
"""
Timestamp in local timezone work. We can't add a timezone to the
string without additional libraries.
"""
ts = TimeStamper(fmt="iso", utc=False)
d = ts(None, None, {})
assert "1980-03-25T16:00:00" == d["timestamp"]

@hynek hynek closed this Oct 24, 2024
@python-mutation-testing
Copy link
Author

Hi,
Sorry if it looked like a bot to you.
I'm a researcher who developed a tool that performs mutation testing for Python projects, considering its dynamic features.
My work has not yet been published, so my profile is like this; it should be anonymous for the review process. This pull request can help me prove my point in my paper.

About the test:

src/structlog/processors.py line 578

self.stamper = TimeStamper(fmt=fmt, utc=utc, key=key)

The utc argument is passed with a True default value, and it is never False (from the MaybeTimeStamper class).
My mutation testing tool deleted the utc argument:

self.stamper = TimeStamper(fmt=fmt, key=key)

And the tests did not fail. I wrote that test to make up for it.
Thanks for your time!

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.

Test formatting when utc is false
2 participants