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

GH648 Allowing dateoffset weekday from relativedelta #1010

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

loicdiridollou
Copy link
Contributor

Comment on lines +1298 to +1302
@pytest.mark.parametrize("weekday", [1, MO, TU, WE, TH, TH, FR, SA, SU])
def test_dateoffset_weekday(weekday: int | WeekdayClass):
"""Check that you can create a `pd.DateOffset` from weekday of int or relativedelta.weekday."""
check(
assert_type(pd.offsets.DateOffset(weekday=weekday), pd.offsets.DateOffset),
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can't use parameterize to do a type checking test.

You will need to have explicit lines with assert_type() for each value you wish to test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure I understand what you mean here.
Having parametrize is (I believe) equivalent to splitting the test in individual tests for all the given parameters. So in my mind this is testing the type individually for each value. Maybe the goal is to make it more readable by having one line for each, if so happy to change it, but let me know if I miss anything with parametrize.
When I run the tests by hand here is what I see:

 pytest tests/test_timefuncs.py::test_dateoffset_weekday -v
========================== test session starts ===========================
platform darwin -- Python 3.12.4, pytest-8.3.2, pluggy-1.5.0 -- /Users/loic.diridollou/Documents/Code/pandas-stubs/venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/loic.diridollou/Documents/Code/pandas-stubs
configfile: pyproject.toml
collected 9 items

tests/test_timefuncs.py::test_dateoffset_weekday[1] PASSED         [ 11%]
tests/test_timefuncs.py::test_dateoffset_weekday[weekday1] PASSED  [ 22%]
tests/test_timefuncs.py::test_dateoffset_weekday[weekday2] PASSED  [ 33%]
tests/test_timefuncs.py::test_dateoffset_weekday[weekday3] PASSED  [ 44%]
tests/test_timefuncs.py::test_dateoffset_weekday[weekday4] PASSED  [ 55%]
tests/test_timefuncs.py::test_dateoffset_weekday[weekday5] PASSED  [ 66%]
tests/test_timefuncs.py::test_dateoffset_weekday[weekday6] PASSED  [ 77%]
tests/test_timefuncs.py::test_dateoffset_weekday[weekday7] PASSED  [ 88%]
tests/test_timefuncs.py::test_dateoffset_weekday[weekday8] PASSED  [100%]

=========================== 9 passed in 0.21s ============================

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.

DateOffset for weekday argument requires weekday argument from dateutil
2 participants