User Tools



Python

The following sections provide information on using Testspace with popular Python test frameworks and tools.

To push the collected result files to Testspace simply use the following client command line:

testspace static-analysis-results test-results code-coverage-results credentials@org-name.testspace.com/project-name/space-name 

where:

For more information on pushing results refer to the Collecting Data article.


Test Frameworks

Unittest

The Python unit testing framework, sometimes referred to as "PyUnit", is a Python language version of JUnit, by Kent Beck and Erich Gamma.

Testspace accepts the JUnit XML formatted Test results. Assuming you are using nose2 to run your tests, here is an example of how to produce such:

nose2 --junit-xml

In the Testspace client command line reference nose2-junit.xml as "test-results" file.

pytest

pytest is a mature full-featured Python testing tool.

Testspace accepts the JUnit XML formatted Test results. Assuming unittest-xml-reporting is installed and configured, here is an example of how to produce such:

py.test --junitxml=results.xml

In the Testspace client command line reference results.xml as "test-results" file.


Code Coverage Tools

Coverage.py

Coverage.py is a tool for measuring code coverage of Python programs.

Testspace accepts the Cobertura XML formatted results. Here is an example of how to produce such:

coverage xml -o coverage.xml

Alternatively, you could direct your test runner to produce the desired coverage results:

  • nose2
nose2 --with-coverage --coverage-report=xml
  • pytest (assuming pytest-cov package has been installed and configured)
py.test --cov-report=xml --cov=./

In the Testspace client command line reference coverage.xml as "code-coverage-results" file.


Static Analysis Tools

flake8

flake8 is a tool for style guide enforcement for Python.

Testspace accepts GCC/Emacs style formatted output logs. Simply write your analysis output to a file:

flake8 --output-file=analysis.log /path/to/source

In the Testspace client command line reference analysis.log{lint} as "static-analysis-results" file.

pycodestyle

pycodestyle is a tool to check Python code against some of the style conventions in PEP 8.

Testspace accepts GCC/Emacs style formatted output logs. Simply write your analysis output to a file:

pycodestyle /path/to/source > analysis.log

In the Testspace client command line reference analysis.log{lint} as "static-analysis-results" file.

Pylint

Pylint is a tool to check Python code against some of the style conventions in PEP 8.

Testspace accepts GCC/Emacs style formatted output logs. Simply write your analysis output to a file:

pylint --output-format=parseable /path/to/source > analysis.log

In the Testspace client command line reference analysis.log{lint} as "static-analysis-results" file.


Page Tools