Changeset 33:d466f464c871 in pyenvjasmine


Ignore:
Timestamp:
Jan 19, 2018, 11:43:48 AM (3 years ago)
Author:
Borja Lopez <borja@…>
Branch:
default
Phase:
public
Message:

Fix for Runner.did_test_pass(), ensuring we catch failed tests
even if they do not appear in the "Failed:" report at the end of the
tests run

Location:
pyenvjasmine
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pyenvjasmine/runner.py

    r30 r33  
    186186
    187187    def did_test_pass(self, stdout):
     188        if 'FAILED' in stdout:
     189            # it can happen that a test fails because of some timing issues
     190            # (timer error). In such case it may happen that the test does
     191            # not appear in the "Failed" report at the end, even if it
     192            # failed, because the execution is interrupted there (no more
     193            # tests are even run afterwards)
     194            #
     195            # in such case, we consider tests failed
     196            return False
     197        # Otherwise, look for a "Failed: 0" status, which we consider as
     198        # tests passing ok
    188199        for line in stdout.splitlines():
    189200            if 'Failed' in line:
  • pyenvjasmine/tests/test_runner.py

    r31 r33  
    9292        finally:
    9393            os.name = old_os_name
     94
     95    def test_did_test_pass(self):
     96        # there is some coverage done with the previous tests,
     97        # but we want to test also the case when a test failed
     98        # and it does not appear in the "Failed:" report
     99        jstests = Runner()
     100        success = jstests.did_test_pass('')
     101        assert not success
     102        success = jstests.did_test_pass('some random data '*50)
     103        assert not success
     104        success = jstests.did_test_pass('some data FAILED some more data')
     105        assert not success
     106        success = jstests.did_test_pass('some data FAILEDsome more data')
     107        assert not success
     108        success = jstests.did_test_pass('Failed: 0')
     109        assert success
     110        success = jstests.did_test_pass('Failed: 0 FAILED')
     111        assert not success
     112        success = jstests.did_test_pass('FAILEDFailed: 0')
     113        assert not success
     114        success = jstests.did_test_pass('Failed: 0FAILED')
     115        assert not success
     116        success = jstests.did_test_pass('Failed: 1')
     117        assert not success
     118        success = jstests.did_test_pass('Failed: -11')
     119        assert not success
     120        success = jstests.did_test_pass('Failed: something-not-a-number')
     121        assert not success
Note: See TracChangeset for help on using the changeset viewer.