# Testing duplicity

## Introduction

Duplicity's tests are code, unit, and functional tests contained in the /testing folder of the main repository.  
There are containers for each version of Python that we actively support.

## Running tests on your branch

The recommended approach is to test duplicity using Docker, to ensure that you are running tests in a known-good
environment. You can run tests on your branch as follows:

1. Install Docker
2. run `testing/docker/build-dupCI.sh` to build containers.  
3. run `testing/docker/run-dupCI.sh` to start the containers.  

Please test your branch using this method and ensure all tests pass before submitting a merge request.

The decorator `@unittest.expectedFailure` can be used to commit a known-failing test case without breaking the test 
suite, for example to exhibit the behaviour in a bug report before it has been fixed.

## Manual testing and running individual tests

1. Docker containers
Even if you wish to run tests manually, we recommend that you do this inside the provided Docker container to ensure
that you have a clean and reproducible environment with all required dependencies for executing these. Please follow
the instructions above. For running a single test, set 
`PYTEST_ARGS` either with an export like `export PYTEST_ARGS=testing/test_code.py` or a temporary setting like 
`PYTEST_ARGS=testing/test_code.py testing/docker/run-dupCI.sh`.
2. Use `pytest` locally if you want to test code on your machine. See 
https://docs.pytest.org/en/stable/contents.html for complete instructions on using `pytest`.
See _Dependencies for testing_ to setup your environment.

## Dependencies for testing
If you should prefer to execute the tests locally without using Docker, see [README-INSTALL.md](README-INSTALL.md) for 
comprehensive `apt` commands to set up your environment (see "APT Only Installation (Development)").
