Changeset 26:14c16e5cbe03 in pyenvjasmine for README.rst


Ignore:
Timestamp:
Jan 18, 2018, 12:22:26 PM (6 years ago)
Author:
Borja Lopez <borja@…>
Branch:
default
Phase:
public
Message:

Replaced nose with py.test and adapted all existing tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • README.rst

    r24 r26  
    3838want to test), install pyenvjasmine and then run::
    3939
    40     nosetests --cover-package=pyenvjasmine --cover-erase \
    41     --with-coverage --with-doctest $*
    42 
    43 .. note::
    44 
    45    If you have installed pyenvjasmine in *development mode*, you can simply
    46    run::
    47 
    48      nosetests -c nose.cfg
    49 
    50    to run the tests from within the pyenvjasmine sources directory.
     40  py.test
    5141
    5242
     
    6151from the js tests on the console. Something like this::
    6252
    63     import unittest
     53    import pytest
    6454    from pyenvjasmine.runner import Runner
    6555
    66     class JavaScriptTests(unittest.TestCase):
     56    class TestJavaScript(object):
    6757        def test_my_javascript(self):
    6858            runner = Runner(
    6959                testdir='/path/to/my/testdir',
    7060                configfile='relative/path/to/configfile')
    71             runner.run(capture_output=False)
    72 
    73 
    74 If you want a more integrated test control, you could set capture_output to
    75 True, then parse the test output that is returned from the run() method, with
    76 something like this::
    77 
    78     import unittest
    79     from pyenvjasmine.runner import Runner
    80 
    81     class JavaScriptTests(unittest.TestCase):
    82         def test_my_javascript_no_output(self):
    83             runner = Runner(
    84                 testdir='/path/to/my/testdir',
    85                 configfile='relative/path/to/configfile')
    86             res = runner.run(capture_output=True)
    87             lines = res.splitlines()
    88             self.assertTrue('Failed: 0' in lines)
     61            success, stdout = runner.run()
     62            # assert on success, will be true if tests passed, False if any
     63            # test failed
     64            assert success
     65            # you can inspect stdout if you want to get more info, but it
     66            # will be printed to the console stdout anyway
     67            assert b'Total: 120' in stdout
    8968
    9069
Note: See TracChangeset for help on using the changeset viewer.