gabrielfalcao/sure

importing sure breaks py.test junit-xml output

Closed this issue · 5 comments

Working case

def test_demo():
    assert True

py.test test_demo.py --junit-xml=junit.xml

junit.xml looks like:

<?xml version="1.0" encoding="utf-8"?>
<testsuite errors="0" failures="0" name="pytest" skips="0" tests="1" time="0.007">
  <testcase classname="test.test_demo" name="test_demo" time="0.000320196151733"/>
</testsuite>

Failing case

Just add an import sure:

import sure
def test_demo():
    assert True

py.test test_demo.py --junit-xml=junit.xml

Now junit.xml is empty:

<?xml version="1.0" encoding="utf-8"?>
<testsuite errors="0" failures="0" name="pytest" skips="0" tests="0" time="0.021">
</testsuite>

I should add that I'm using Python 2.7, sure 1.2.7, and pytest 2.6.4

I can reproduce this issue.
It seems like py.test thinks that there are 3 test cases - all the same test_demo one.
However, none of those end up in the junit.xml.

The pytestdebug.log can be found here: https://gist.github.com/timofurrer/c563cf226d763783faca8137ce6a90b7

its not 3 tests, just the 3 phases of the test, namely setup, call, teardown

@mcbridejc I didn't investigate a lot on this issue. However, what you can do in the meantime is disable the monkey-patching by setting the env variable SURE_DISABLE_NEW_SYNTAX to false. Thus, your py.test call could look like:

SURE_DISABLE_NEW_SYNTAX=false py.test test_demo.py --junit-xml=junit.xml

As I said - the monkey-patching will be disabled with that but you can use the equally beautiful expect():

expect("hello world".split()).to.be.equal(["hello", "world"])

This will be fixed when #74 is merged and released!