source: pyenvjasmine/README.rst@ 21:40b68b918abc

Last change on this file since 21:40b68b918abc was 21:40b68b918abc, checked in by Borja Lopez <borja@…>, 9 years ago

Bumped to version 0.1.5:

  • Replaced 'setup.py develop' with 'pip install -e' in the README (setup.py develop does not work right now for us)
  • Updated setup.py classifiers to reflect the change from ZPL to BSD
  • Updated MANIFEST with the latest additions after imported the proper version of envjasmine
File size: 2.6 KB
RevLine 
[0]1Python envjasmine wrapper
2=========================
3
4This is a thin python wrapper around the envjasmine_ JavaScript
5testing framework.
6
[8]7
8.. contents::
9
10
11Installation
12------------
13
14You can install pyenvjasmine using pip_ or easy_install_::
15
16 pip install pyenvjasmine
17
18::
19
20 easy_install pyenvjasmine
21
22Or you can grab the latest sources and install it from there::
23
24 python setup.py install
25
26Also, you can use it directly from the sources directory, in *development mode*
27(useful if you want to contribute to the project)::
28
[21]29 pip install -e .
[8]30
31.. note::
32
33 More about the *development mode* here:
34
35 https://packaging.python.org/en/latest/distributing.html#working-in-development-mode
[0]36
37
[11]38Running pyenvjasmine tests
39--------------------------
[0]40
[11]41To run the tests on this code here (as opposed to *your* JavaScript code you
42want to test), install pyenvjasmine and then run::
[0]43
44 nosetests --cover-package=pyenvjasmine --cover-erase \
45 --with-coverage --with-doctest $*
46
[8]47.. note::
48
49 If you have installed pyenvjasmine in *development mode*, you can simply
50 run::
51
[11]52 nosetests -c nose.cfg
[8]53
[11]54 to run the tests from within the pyenvjasmine sources directory.
[8]55
[0]56
57Run your own tests
58------------------
59
[11]60The easiest way is to put your "specs" (JavaScript tests) into some directory
61in your code, then in your python tests, add a new TestCase with just one test
62that runs all your JavaScript tests.
[0]63
[11]64The simplest solution is to set capture_output to False, so you see the output
65from the js tests on the console. Something like this::
[0]66
67 import unittest
68 from pyenvjasmine.runner import TestRunner
69
70 class JavaScriptTests(unittest.TestCase):
71 def test_my_javascript(self):
72 runner = TestRunner(
73 testdir='/path/to/my/testdir',
74 configfile='relative/path/to/configfile')
75 runner.run(capture_output=False)
76
77
[11]78If you want a more integrated test control, you could set capture_output to
79True, then parse the test output that is returned from the run() method, with
80something like this::
[0]81
[11]82 import unittest
83 from pyenvjasmine.runner import TestRunner
84
85 class JavaScriptTests(unittest.TestCase):
[0]86 def test_my_javascript_no_output(self):
87 runner = TestRunner(
88 testdir='/path/to/my/testdir',
89 configfile='relative/path/to/configfile')
90 res = runner.run(capture_output=True)
91 lines = res.splitlines()
92 self.assertTrue('Failed: 0' in lines)
93
[8]94
95.. _envjasmine : https://github.com/trevmex/EnvJasmine
96.. _pip: http://www.pip-installer.org/en/latest/index.html
97.. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall
Note: See TracBrowser for help on using the repository browser.