aboutsummaryrefslogtreecommitdiffstats
path: root/tests/README.rst
blob: 2b3afb8b93e647a00948687d0c4129af8bfc0cb1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
.. title: The Nikola Test Suite
.. slug: tests
.. date: 2012/03/30 23:00

The Nikola Test Suite
=====================

Nikola, like many software projects, has a test suite.  There are over 100
tests.

Tests (in alphabetical order)
-----------------------------

* ``test_command_import_wordpress`` tests the WordPress importer for
  Nikola.
* ``test_command_init`` checks whether new sites are created properly via the
  ``init`` command.
* ``test_compile_markdown`` exercises the Markdown compiler plugin of Nikola.
* ``test_integration`` are used to validate that sites actually build.
* ``test_locale`` tests the locale support of Nikola.
* ``test_plugin_importing`` checks three basic plugins to know whether they
  get imported properly.
* ``test_rss_feeds`` asserts that RSS created by Nikola is sane.
* ``test_rst_compiler`` exercises the reStructuredText compiler plugin of
  Nikola.
* ``test_scheduling`` performs tests on post scheduling rules.
* ``test_utils`` test various Nikola utilities.

Requirements to run the tests
-----------------------------

You need:

* ``pip install -r requirements-tests.txt``
* a few minutes’ time
* appropriate locale settings

How to set the locale for Nikola tests?
---------------------------------------

For testing nikola needs to specify two languages, each one with a supported locale. By default, the test suite uses ``en`` and ``es`` as languages, and their respective default locale for them.

You can set the language - locale pairs by exporting two shell variables, like in::

    export NIKOLA_LOCALE_DEFAULT=en,en_US.utf8
    export NIKOLA_LOCALE_OTHER=es,es_ES.utf8

In Windows that would be::

	set NIKOLA_LOCALE_DEFAULT=en,English 
	set NIKOLA_LOCALE_OTHER=es,Spanish
	
Replace the part before the comma with a Nikola translation selector (see ``nikola/conf.py.in`` for details), and the part after the comma with an *installed* glibc locale.

To check if the desired locale is supported in your host you can, in a python console::

	import locale
	locale.setlocale(locale.LC_ALL, 'locale_name')
    # by example, 'en_US.utf8' (posix) 'English' (windows)
	# if it does not traceback, then python can use that locale

Alternatively, if you have some disk space to spare, you can install
the two default locales. Here is how to do that in Ubuntu::

    sudo apt-get install language-pack-en language-pack-es

	
How to execute the tests
------------------------

The command to execute tests is::

    nosetests --with-coverage --cover-package=nikola --with-doctest --doctest-options=+NORMALIZE_WHITESPACE --logging-filter=-yapsy

However, this command may change at any given moment.  Check the
``/.travis.yml`` file to get the current command.

In Windows you want to drop the doctests parts, they fail over trivial differences in OS details.

It is also recommended to run ``nikola help`` to see if Nikola actually
works.

If you are committing code, make sure to run ``flake8 --ignore=E501 .`` to see if you comply with the PEP 8 style guide and do not have basic code mistakes (we ignore the 79-characters-per-line rule).

In windows ignore the two flake8 diagnostics about messages_sl_si.py , they are artifacts of (symlinks + git + windows).


Travis CI
---------

We also run our tests on `Travis CI <https://travis-ci.org/>`_.
You can check the `current build status <https://travis-ci.org/getnikola/nikola>`_ there.