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

Use assert ... is True in XFAIL tests #15817

Merged
merged 1 commit into from Jan 22, 2019

Conversation

oscarbenjamin
Copy link
Contributor

Brief description of what is fixed or changed

Changes failing asserts in xfail tests to use assert ... is True rather than just assert .... Otherwise the result is assert None which triggers a warning under pytest

Other comments

I raised this as an issue with pytest: pytest-dev/pytest#4639.

Release Notes

NO ENTRY

@sympy-bot
Copy link

Hi, I am the SymPy bot (v135). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

  • No release notes entry will be added for this pull request.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

#### Brief description of what is fixed or changed

Changes failing asserts in xfail tests to use `assert ... is True` rather than just `assert ...`. Otherwise the result is `assert None` which triggers a warning under pytest

#### Other comments

I raised this as an issue with `pytest`: [https://github.com/pytest-dev/pytest/issues/4639](https://github.com/pytest-dev/pytest/issues/4639).

#### Release Notes

<!-- BEGIN RELEASE NOTES -->
NO ENTRY
<!-- END RELEASE NOTES -->

@@ -735,7 +735,7 @@ def test_J16():

@XFAIL
def test_J17():
assert deltaintegrate(f((x + 2)/5)*DiracDelta((x - 2)/3) - g(x)*diff(DiracDelta(x - 1), x), (x, 0, 3))
raise NotImplementedError("deltaintegrate(f((x + 2)/5)*DiracDelta((x - 2)/3) - g(x)*diff(DiracDelta(x - 1), x), (x, 0, 3))")
Copy link
Member

Choose a reason for hiding this comment

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

How about

Suggested change
raise NotImplementedError("deltaintegrate(f((x + 2)/5)*DiracDelta((x - 2)/3) - g(x)*diff(DiracDelta(x - 1), x), (x, 0, 3))")
assert deltaintegrate(f((x + 2)/5)*DiracDelta((x - 2)/3) - g(x)*diff(DiracDelta(x - 1), x), (x, 0, 3)) is not None

(or better, assert that it equals the correct answer).

XFAIL tests should ideally xpass once they start working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What you're saying makes sense and I fully agree. I think that an xfail test should not only xpass when working but should actually be a reasonable non-xfail test of the correct behaviour.

Happy to change it but if you look at the surrounding code though you'll see why I did it like this.

Copy link
Member

Choose a reason for hiding this comment

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

I actually don't understand this test. Why is it testing the internal deltaintegrate function? For whatever reason, it doesn't work, even if you split up the integral, but integrate itself works just fine:

>>> integrate(f((x + 2)/5)*DiracDelta((x - 2)/3) - g(x)*diff(DiracDelta(x - 1), x), (x, 0, 3))
3*f(4/5) + Subs(Derivative(g(x), x), x, 1)

The Wester tests should be testing the public APIs.

So I actually think we should change this test to a passing one that tests the above.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
raise NotImplementedError("deltaintegrate(f((x + 2)/5)*DiracDelta((x - 2)/3) - g(x)*diff(DiracDelta(x - 1), x), (x, 0, 3))")
assert integrate(f((x + 2)/5)*DiracDelta((x - 2)/3) - g(x)*diff(DiracDelta(x - 1), x), (x, 0, 3)) == 3*f(S(4)/5) + Subs(Derivative(g(x), x), x, 1)

@asmeurer
Copy link
Member

I have just the one comment. I don't really understand why pytest has an issue with assert None, but this seems fine.

@oscarbenjamin
Copy link
Contributor Author

I don't agree with pytest's issue with assert None. It seems unnecessary but at the same time I can see the argument that it is better to be explicit in tests and write assert f() is True rather than assert f() which almost any random object would pass.

This silences a warning about asserting None when running tests under
pytest.
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.

None yet

4 participants