Changeset 26:14c16e5cbe03 in pyenvjasmine for pyenvjasmine/tests/test_runner.py


Ignore:
Timestamp:
Jan 18, 2018, 12:22:26 PM (3 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
  • pyenvjasmine/tests/test_runner.py

    r24 r26  
    1 import unittest
    21import os
     2import pytest
    33
    4 from pyenvjasmine.runner import Runner
     4from pyenvjasmine.runner import Runner, get_environment
    55
    66
    7 class RunnerTests(unittest.TestCase):
    8     def setUp(self):
    9         pass
    10 
    11     def tearDown(self):
    12         pass
     7class TestsRunner(object):
    138
    149    def test_runner_defaults(self):
     
    1712        """
    1813        jstests = Runner()
    19         output = jstests.run()
     14        success, stdout = jstests.run()
     15        assert success
    2016        # output is the resulting stdout from a subprocess call, which is a
    2117        # bytes object, hence the b'' for the checks
    22         self.assertTrue(b'Failed: 0' in output)
    23         self.assertTrue(b'Passed: 5' in output)
     18        assert b'Failed: 0' in stdout
     19        assert b'Passed: 5' in stdout
    2420
    2521    def test_runner_params(self):
     
    3632            configfile=conf_file,
    3733        )
    38         output = jstests.run(spec='tests/specs/test_demo.spec.js')
    39         lines = output.splitlines()
     34        success, stdout = jstests.run(spec='tests/specs/test_demo.spec.js')
     35        lines = stdout.splitlines()
    4036        # output is the resulting stdout from a subprocess call, which is a
    4137        # bytes object, hence the b'' in the endswith/startswith calls
    42         self.assertTrue(lines[0].endswith(b'specs/test_demo.spec.js'),
    43             "wrong output: %s" % str(output))
    44         self.assertTrue(lines[1].startswith(b'[  Envjs/1.6 (Rhino;'),
    45             "wrong output: %s" % str(output))
    46         self.assertTrue(b'Passed: 4' in lines)
    47         self.assertTrue(b'Failed: 0' in lines)
    48         self.assertTrue(b'Total : 4' in lines)
     38        assert lines[0].endswith(b'specs/test_demo.spec.js')
     39        assert lines[1].startswith(b'[  Envjs/1.6 (Rhino;')
     40        assert b'Passed: 4' in lines
     41        assert b'Failed: 0' in lines
     42        assert b'Total : 4' in lines
    4943
    5044    def test_write_browser_htmlfile_markup_is_correct(self):
     
    6559        with open("browser.runner.html",'r') as file:
    6660            actual = file.read()
    67             self.assertEqual(expected, actual)
     61            assert expected == actual
    6862
    6963    def test_runner_with_browser_configfile(self):
     
    8074            browser_configfile=browser_conf_file
    8175        )
    82         jstests.run(spec='tests/specs/test_demo.spec.js')
     76        success, stdout = jstests.run(spec='tests/specs/test_demo.spec.js')
     77        assert not success
    8378
    8479    def test_get_environment(self):
     
    8883        so monkey patching the old way.
    8984        """
    90         from pyenvjasmine.runner import get_environment
    91         import os
    9285        old_os_name = os.name
    9386        try:
    9487            os.name = 'nt'
    9588            res = get_environment()
    96             self.assertEqual(res, '--environment=WIN')
     89            assert res == '--environment=WIN'
    9790            os.name = 'posix'
    9891            res = get_environment()
    99             self.assertEqual(res, '--environment=UNIX')
     92            assert res == '--environment=UNIX'
    10093        finally:
    10194            os.name = old_os_name
    102 
    103     def test_not_capture_output(self):
    104         """
    105         Running a test without capturing output
    106         """
    107         jstests = Runner()
    108         output = jstests.run(capture_output=False)
    109         self.assertEqual(output, None)
Note: See TracChangeset for help on using the changeset viewer.