source: pyenvjasmine/README.rst@ 8:042bf77e0223

Last change on this file since 8:042bf77e0223 was 8:042bf77e0223, checked in by Borja Lopez <borja@…>, 9 years ago

Added basic installation instructions, updated section on how to run pyenvjasmine tests

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
29 python setup.py develop
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
38Running the tests of this python module:
39----------------------------------------
40
41To run the tests on this code here (as opposed to *your* JavaScript
42code you want to test), install this into a virtualenv, install
43nose and maybe coverage in that virtualenv and then run::
44
45 nosetests --cover-package=pyenvjasmine --cover-erase \
46 --with-coverage --with-doctest $*
47
[8]48.. note::
49
50 If you have installed pyenvjasmine in *development mode*, you can simply
51 run::
52
53 nosetests
54
55 to run the tests.
56
[0]57
58Run your own tests
59------------------
60
61The easiest way is to put your "specs" (JavaScript tests) into
62some directory in your code, then in your python tests, add a new
63TestCase with just one test that runs all your JavaScript tests.
64
65The simplest solution is to set capture_output to False, so you see
66the output from the js tests on the console. Something like this::
67
68 import unittest
69 from pyenvjasmine.runner import TestRunner
70
71 class JavaScriptTests(unittest.TestCase):
72 def test_my_javascript(self):
73 runner = TestRunner(
74 testdir='/path/to/my/testdir',
75 configfile='relative/path/to/configfile')
76 runner.run(capture_output=False)
77
78
79If you want a more integrated
80test control, you could set capture_output to True, then parse the test
81output that is returned from the run() method, with something like this::
82
83 def test_my_javascript_no_output(self):
84 runner = TestRunner(
85 testdir='/path/to/my/testdir',
86 configfile='relative/path/to/configfile')
87 res = runner.run(capture_output=True)
88 lines = res.splitlines()
89 self.assertTrue('Failed: 0' in lines)
90
[8]91
92.. _envjasmine : https://github.com/trevmex/EnvJasmine
93.. _pip: http://www.pip-installer.org/en/latest/index.html
94.. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall
Note: See TracBrowser for help on using the repository browser.