about summary refs log tree commit diff
path: root/doc/languages-frameworks
diff options
context:
space:
mode:
authorFrederik Rietdijk <fridh@fridh.nl>2017-09-02 12:06:37 +0200
committerFrederik Rietdijk <fridh@fridh.nl>2017-09-02 12:06:50 +0200
commitb7d257a5207f3b7e9cfe002e8b77853c97d5b697 (patch)
treeb52ab4ed8ec70127aa3cbc8c966d2bab40f60c23 /doc/languages-frameworks
parent54ae0aa1b08efbb82d76dbe5601e06cf7dc7a8b1 (diff)
Python docs: add section on tests
Diffstat (limited to 'doc/languages-frameworks')
-rw-r--r--doc/languages-frameworks/python.md20
1 files changed, 18 insertions, 2 deletions
diff --git a/doc/languages-frameworks/python.md b/doc/languages-frameworks/python.md
index f2de0225b1d68..298da8f9f0d2b 100644
--- a/doc/languages-frameworks/python.md
+++ b/doc/languages-frameworks/python.md
@@ -774,6 +774,21 @@ The `buildPythonPackage` function sets `DETERMINISTIC_BUILD=1` and
 Both are also exported in `nix-shell`.
 
 
+### Automatic tests
+
+It is recommended to test packages as part of the build process.
+Source distributions (`sdist`) often include test files, but not always.
+
+By default the command `python setup.py test` is run as part of the
+`checkPhase`, but often it is necessary to pass a custom `checkPhase`. An
+example of such a situation is when `py.test` is used.
+
+#### Common issues
+
+- Non-working tests can often be deselected. In the case of `py.test`: `py.test -k 'not function_name and not other_function'`.
+- Unicode issues can typically be fixed by including `glibcLocales` in `buildInputs` and exporting `LC_ALL=en_US.utf-8`.
+- Tests that attempt to access `$HOME` can be fixed by using the following work-around before running tests (e.g. `preCheck`): `export HOME=$(mktemp -d)`
+
 ## FAQ
 
 ### How to solve circular dependencies?
@@ -985,8 +1000,9 @@ rec {
 
 Following rules are desired to be respected:
 
-* Python libraries are supposed to be called from `python-packages.nix` and packaged with `buildPythonPackage`. The expression of a library should be in `pkgs/development/python-modules/<name>/default.nix`. Libraries in `pkgs/top-level/python-packages.nix` are sorted quasi-alphabetically to avoid merge conflicts.
+* Python libraries are called from `python-packages.nix` and packaged with `buildPythonPackage`. The expression of a library should be in `pkgs/development/python-modules/<name>/default.nix`. Libraries in `pkgs/top-level/python-packages.nix` are sorted quasi-alphabetically to avoid merge conflicts.
 * Python applications live outside of `python-packages.nix` and are packaged with `buildPythonApplication`.
 * Make sure libraries build for all Python interpreters.
 * By default we enable tests. Make sure the tests are found and, in the case of libraries, are passing for all interpreters. If certain tests fail they can be disabled individually. Try to avoid disabling the tests altogether. In any case, when you disable tests, leave a comment explaining why.
-* Commit names of Python libraries should include `pythonPackages`, for example `pythonPackages.numpy: 1.11 -> 1.12`.
+* Commit names of Python libraries should reflect that they are Python libraries, so write for example `pythonPackages.numpy: 1.11 -> 1.12`.
+