Can't get unittest to run


  • Pybytes Beta

    I installed this library which includes a test of unittest itself.

    However, when I import test_unittest it does nothing. If I edit line 114 of test_unittest.py as per the below I get "Ran 0 tests"

    So... how the heck do I use unittest on the WiPy?

    Line 114 before:

    if __name__ == '__main__':
        unittest.main()
    
    
    >>> import test_unittest
    >>>
    

    Edited:

    #if __name__ == '__main__':
    unittest.main()
    
    
    >>> import test_unittest
    Ran 0 tests
    >>>
    

    Plain vanilla assert works on the WiPy.

    >>> assert 1 == 1, 'Not equal'
    >>> assert 1 == 2, 'Not equal'
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AssertionError: Not equal
    >>>
    

    Same test using Cygwin Python 3.6 on my Windows laptop:

    $ python3 test_unittest.py
    ...........s...
    ----------------------------------------------------------------------
    Ran 15 tests in 0.031s
    
    OK (skipped=1)
    
    $

  • Pybytes Beta

    This post is deleted!

Log in to reply
 

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.