|
1 | | -# Unit tests for Weaviate Python client |
2 | | ---- |
3 | | -Unit tests for weaviate package. Each module should have its own sub-directory in the `test` directory. Each test file should begin with `test_<fine_name>.py` and `test` directory should not be renamed, these are mandatory requirements for the `unittest` to parse and run all unittests. |
4 | | - |
5 | | -The `util.py` contains helper functions for unit testing. |
6 | | - |
7 | | ---- |
8 | | -## Run one file unittest |
9 | | -In order to unit test a single file, you can run the following command: |
10 | | -``` |
11 | | -python -m unittest path_to_file_dir.file |
12 | | -``` |
13 | | -E.g. if you run it from repo root folder: |
14 | | -```bash |
15 | | -python -m unittest test.gql.test_get -v # -v is optional, -v = verbose |
16 | | -``` |
17 | | -## Run whole package unittest |
18 | | -In order to unit test the whole package, you can run the following command: |
19 | | -```bash |
20 | | -python -m unittest -v # -v is optional, -v = verbose |
21 | | -``` |
22 | | - |
23 | | -# Coverage test |
24 | | ---- |
25 | | -Coverage test for weaviate package. Coverage test can be performed using the existing unit test. It runs all the unit tests in order to find which parts of the code have been executed, thus it can be used instead of the Unit test. |
26 | | -Coverage test is performed by the `coverage` package that should be installed with the `development-requirements.txt`. For more information on what and how to run coverage tests visit this [link](https://coverage.readthedocs.io/en/coverage-5.3.1/ "coverage.readthedocs.io"). |
27 | | - |
28 | | ---- |
29 | | - |
30 | | -## Run coverage test for one file |
31 | | -Coverage test for one file can be performed using the following command: |
32 | | -```bash |
33 | | -coverage run -m unittest path_to_the_file_dir.file -v # -v is optional, -v = verbose |
34 | | -``` |
35 | | -E.g. if you run it from repo root folder: |
36 | | -```bash |
37 | | -coverage run -m unittest test.gql.test_get -v # -v is optional, -v = verbose |
38 | | -``` |
39 | | - |
40 | | -## Run whole package coverage test |
41 | | -In order to unit test the whole package, you can run the following command: |
42 | | -```bash |
43 | | -coverage run -m unittest -v # -v is optional, -v = verbose |
44 | | -``` |
45 | | -## Show coverage report |
46 | | -To get the coverage report run the following command. |
47 | | -```bash |
48 | | -coverage report -m --skip-covered # --skip-covered = skip 100% covered files, -m = show missing lines |
49 | | -``` |
50 | | - |
51 | | -# Linting |
52 | | ---- |
53 | | -Lint the files that are modified before commiting. The linting is done by `pylint`. |
54 | | - |
55 | | -To lint a file/module/package run the following command: |
56 | | -```bash |
57 | | -pylint path_to_the_file_or_module |
58 | | -``` |
59 | | -E.g. if you run it from repo root folder: |
60 | | -```bash |
61 | | -pylint weaviate # for the whole package |
62 | | -pylint weaviate/batch # for the module batch |
63 | | -pylint weaviate/connect/connection.py # for the connection.py file |
64 | | -``` |
| 1 | +Refer to [CONTRIBUTING.md](CONTRIBUTING.md) file for instructions on how to run the tests. |
0 commit comments