blob: 4337b47ce6b357ceeff024cf9fecf10745b82344 [file] [log] [blame]
Alex Stapletonc5fffd32014-03-18 15:29:00 +00001Getting started
Paul Kehrer0839aa82014-02-11 22:36:51 -06002===============
3
4Working on ``cryptography`` requires the installation of a small number of
Nic Young96fb5332014-06-12 08:25:42 -06005development dependencies in addition to the dependencies for :doc:`/installation`.
Nic Young2e8aa562014-06-12 00:17:50 -06006These are listed in ``dev-requirements.txt`` and they can be installed in a
7`virtualenv`_ using `pip`_. Once you've installed the dependencies, install
8``cryptography`` in ``editable`` mode. For example:
Paul Kehrer0839aa82014-02-11 22:36:51 -06009
10.. code-block:: console
11
Paul Kehrer450cd022014-02-11 22:46:39 -060012 $ # Create a virtualenv and activate it
13 $ pip install --requirement dev-requirements.txt
14 $ pip install --editable .
Paul Kehrer0839aa82014-02-11 22:36:51 -060015
16You are now ready to run the tests and build the documentation.
17
Alex Stapletonc5fffd32014-03-18 15:29:00 +000018Running tests
Paul Kehrer0839aa82014-02-11 22:36:51 -060019~~~~~~~~~~~~~
20
21``cryptography`` unit tests are found in the ``tests/`` directory and are
22designed to be run using `pytest`_. `pytest`_ will discover the tests
23automatically, so all you have to do is:
24
25.. code-block:: console
26
Paul Kehrer450cd022014-02-11 22:46:39 -060027 $ py.test
28 ...
29 62746 passed in 220.43 seconds
Paul Kehrer0839aa82014-02-11 22:36:51 -060030
31This runs the tests with the default Python interpreter.
32
33You can also verify that the tests pass on other supported Python interpreters.
34For this we use `tox`_, which will automatically create a `virtualenv`_ for
35each supported Python version and run the tests. For example:
36
37.. code-block:: console
38
Paul Kehrer450cd022014-02-11 22:46:39 -060039 $ tox
40 ...
41 ERROR: py26: InterpreterNotFound: python2.6
42 py27: commands succeeded
43 ERROR: pypy: InterpreterNotFound: pypy
44 ERROR: py32: InterpreterNotFound: python3.2
45 py33: commands succeeded
46 docs: commands succeeded
47 pep8: commands succeeded
Paul Kehrer0839aa82014-02-11 22:36:51 -060048
49You may not have all the required Python versions installed, in which case you
50will see one or more ``InterpreterNotFound`` errors.
51
52
Alex Stapletonc5fffd32014-03-18 15:29:00 +000053Explicit backend selection
Paul Kehrer0839aa82014-02-11 22:36:51 -060054~~~~~~~~~~~~~~~~~~~~~~~~~~
55
56While testing you may want to run tests against a subset of the backends that
57cryptography supports. Explicit backend selection can be done via the
58``--backend`` flag. This flag should be passed to ``py.test`` with a comma
Paul Kehrer18962cc2014-02-11 22:54:40 -060059delimited list of backend names.
60
61
62.. code-block:: console
63
64 $ tox -- --backend=openssl
65 $ py.test --backend=openssl,commoncrypto
Paul Kehrer0839aa82014-02-11 22:36:51 -060066
Alex Stapletonc5fffd32014-03-18 15:29:00 +000067Building documentation
Paul Kehrer0839aa82014-02-11 22:36:51 -060068~~~~~~~~~~~~~~~~~~~~~~
69
70``cryptography`` documentation is stored in the ``docs/`` directory. It is
71written in `reStructured Text`_ and rendered using `Sphinx`_.
72
73Use `tox`_ to build the documentation. For example:
74
75.. code-block:: console
76
Paul Kehrer450cd022014-02-11 22:46:39 -060077 $ tox -e docs
78 ...
79 docs: commands succeeded
80 congratulations :)
Paul Kehrer0839aa82014-02-11 22:36:51 -060081
82The HTML documentation index can now be found at
83``docs/_build/html/index.html``.
84
85.. _`pytest`: https://pypi.python.org/pypi/pytest
86.. _`tox`: https://pypi.python.org/pypi/tox
87.. _`virtualenv`: https://pypi.python.org/pypi/virtualenv
88.. _`pip`: https://pypi.python.org/pypi/pip
89.. _`sphinx`: https://pypi.python.org/pypi/Sphinx
90.. _`reStructured Text`: http://sphinx-doc.org/rest.html