Issue #57 resolved

New assertion logic no longer follows Python short circuit logic

Jason R. Coombs avatarJason R. Coombs created an issue

I installed the pre-release 2.1.0.dev4 in our environment (to get the fix for #47), but it caused a failure in our test suite. The test is still correct, but it appears the way pytest interprets the assertion, it now fails.

A simple test that reproduces the failure is here:

def test_short_circuit():
    subject = 1   # sometimes 'var'
    assert subject == 1 or '$'+subject == '$var'

In our actual test, this test makes perfect sense. If the number doesn't match, it should be a string and will be concatenated properly.

Prior to pytest, this test passes. With 2.1.0.dev4, it fails with a TypeError: cannot concatenate 'str' and 'int' objects.

I'm assigning this initially to Bejamin Peterson as I believe he's most familiar with the new assertion code.

Will it be possible to restore the original assertion code to match the previous, short-circuited behavior?

Comments (2)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.