Skip to content

CLN: Use assert_produces_warning instead of pytest.raises to show FutureWarning #56716

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

Closed
natmokval opened this issue Jan 3, 2024 · 5 comments · Fixed by #56974
Closed

CLN: Use assert_produces_warning instead of pytest.raises to show FutureWarning #56716

natmokval opened this issue Jan 3, 2024 · 5 comments · Fixed by #56974
Labels
Clean good first issue Testing pandas testing functions or related to the test suite

Comments

@natmokval
Copy link
Contributor

In some places we raise FutureWarning using pytest:

with pytest.raises(FutureWarning, match=msg):

Find and replace it with tm.assert_produces_warning

@natmokval natmokval self-assigned this Jan 3, 2024
@rhshadrach rhshadrach added the Testing pandas testing functions or related to the test suite label Jan 3, 2024
@pmhatre1
Copy link
Contributor

pmhatre1 commented Jan 3, 2024

I could find this FutureWarning in test_xml.py under the method test_empty_stylesheet(val) only @natmokval @rhshadrach

@pmhatre1
Copy link
Contributor

pmhatre1 commented Jan 4, 2024

Not sure why the checks are failing even before I replace the original code with tm.assert_produces_warning?

@natmokval
Copy link
Contributor Author

natmokval commented Jan 4, 2024

I could find this FutureWarning in test_xml.py under the method test_empty_stylesheet(val) only

Yes, it's partially correct. We have another method in pandas/tests/io/xml/test_xml.py that contains pytest.raises(FutureWarning, match=msg) too.

@natmokval
Copy link
Contributor Author

Not sure why the checks are failing even before I replace the original code with tm.assert_produces_warning?

thank you for working on it @pmhatre1.
Try this:
pytest pandas/tests/io/xml/test_xml.py -k test_empty_stylesheet
the test should pass

@natmokval natmokval removed their assignment Jan 4, 2024
@pmhatre1
Copy link
Contributor

pmhatre1 commented Jan 6, 2024

@natmokval The checks are still failing. The main reason after debugging, I found is that the path to the stylesheet and xml is not correct. I had to give absolute path to open the xml. Also, the Future warning is not working in my case. There is no try catch if the path to stylesheet is not given. In case you want to correct me or am I missing something here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean good first issue Testing pandas testing functions or related to the test suite
Projects
None yet
4 participants