dimanche 5 juin 2016

How to make nosetests ignore test depending on used Python version?

I've got my .travis.yml setup in a Github repository, and I'm performing nosetests for Python 2.7 and Python 3.4 using a tests.py file to run a series of tests, which all works great.

Below is one of my tests. Notice I'm only asserting if Python version is 2.x.x:

def test_sip_api_already_set():
    """Qt.py should cause ImportError when sip API v1 was already set
    (Python 2.x only)"""

    with pyqt4():
        def import_qt():
            import Qt

        if sys.version_info[0] == 2:
            # Python 2.x

            from PyQt4 import QtCore
            import sip
            sip.setapi("QString", 1)
            assert_raises(ImportError, import_qt)

When I run my tests I see this both for Python 2.7 and Python 3.4:

Qt.py should cause ImportError when sip API v1 was already set ... ok

I don't want this tests to show up at all in nosetests when using Python 3.4. How can I make this test not run or not show up in the nosetests summary when being run with Python 3.4?

Aucun commentaire:

Enregistrer un commentaire