Skip to content

Commit 1ea0cfb

Browse files
authored
Merge pull request #228 from DerwenAI/pytest-basics
Implement pytest for current tests
2 parents 59e6047 + be0e694 commit 1ea0cfb

10 files changed

+317
-317
lines changed

.bandit

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[bandit]
22
exclude_dirs:
33
- examples
4-
exclude: setup.py,test.py
4+
- tests
5+
exclude: setup.py

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ repos:
1717
rev: 1.7.0
1818
hooks:
1919
- id: bandit # security vulnerabilities
20-
args: [ "--exclude", "setup.py,bin,test.py" ]
20+
args: [ "--exclude", "setup.py,bin,tests" ]
2121
- repo: https://github.com/pre-commit/mirrors-mypy
2222
rev: v0.812
2323
hooks:
2424
- id: mypy # type annotations
25-
exclude: ^examples/,^wip/,^test.py
25+
exclude: ^examples/,^wip/,^tests/
2626
- repo: https://github.com/PyCQA/pylint
2727
rev: pylint-2.7.2
2828
hooks:
2929
- id: pylint
30-
exclude: ^wip/,^test.py
30+
exclude: ^wip/,^tests/
3131
files: ^kglab/
3232
- repo: https://github.com/codespell-project/codespell
3333
rev: v2.0.0

docker/Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ COPY ./kglab /opt/kglab/kglab
3737
COPY ./dat /opt/kglab/dat
3838
COPY ./examples /opt/kglab/examples
3939
COPY ./requirements*.txt /opt/kglab/
40-
COPY ./test.py /opt/kglab/
4140
COPY ./sample.py /opt/kglab/
4241

4342
## create a known user ID

docker/Dockerfile.common

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ COPY ./kglab /opt/kglab/kglab
3737
COPY ./dat /opt/kglab/dat
3838
COPY ./examples /opt/kglab/examples
3939
COPY ./requirements*.txt /opt/kglab/
40-
COPY ./test.py /opt/kglab/
4140
COPY ./sample.py /opt/kglab/
4241

4342
## create a known user ID

docker/Dockerfile.testsuite

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ FROM kglab as testsuite
66
WORKDIR /opt/kglab
77
USER appuser
88

9+
COPY ./tests/* /opt/kglab/tests/
10+
911
RUN set -eux; \
1012
source /opt/kglab/venv/bin/activate ; \
1113
/opt/kglab/venv/bin/python3.8 -m pip install -r /opt/kglab/requirements-dev.txt
1214

13-
CMD /opt/kglab/venv/bin/python3.8 /opt/kglab/test.py
15+
CMD /opt/kglab/venv/bin/python3.8 -m pytest tests/

docker/testsuite.Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ COPY ./kglab /opt/kglab/kglab
3737
COPY ./dat /opt/kglab/dat
3838
COPY ./examples /opt/kglab/examples
3939
COPY ./requirements*.txt /opt/kglab/
40-
COPY ./test.py /opt/kglab/
40+
COPY ./tests/ /opt/kglab/tests/
4141
COPY ./sample.py /opt/kglab/
4242

4343
## create a known user ID
@@ -70,4 +70,4 @@ RUN set -eux; \
7070
source /opt/kglab/venv/bin/activate ; \
7171
/opt/kglab/venv/bin/python3.8 -m pip install -r /opt/kglab/requirements-dev.txt
7272

73-
CMD /opt/kglab/venv/bin/python3.8 /opt/kglab/test.py
73+
CMD /opt/kglab/venv/bin/python3.8 -m pytest tests/

docs/build.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ This project uses `unittest` and
7979
[`coverage`](https://coverage.readthedocs.io/)
8080
for *unit test* coverage.
8181
Source for unit tests is in the
82-
[`test.py`](https://github.com/DerwenAI/kglab/blob/main/test.py)
82+
[`tests/`](https://github.com/DerwenAI/kglab/blob/main/tests/)
8383
module.
8484

8585
To run unit tests:
@@ -100,7 +100,7 @@ Test coverage reports can be viewed at
100100
The CI pipeline will test automatically for each pull request,
101101
although to run these tests manually:
102102
```
103-
python3 ./test.py
103+
python3 -m pytest tests/
104104
python3 -m pytest --nbmake examples/
105105
```
106106

@@ -153,7 +153,7 @@ release process:
153153

154154
```
155155
python3 -m pip install -e .
156-
python3 ./test.py
156+
python3 -m pytest tests/
157157
python3 -m pip uninstall kglab
158158
```
159159

requirements-dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pre-commit
1717
pygments >= 2.7.4
1818
pylint >= 2.7.0
1919
pymdown-extensions
20+
pytest
2021
scikit-learn >= 0.20.2
2122
selenium
2223
twine

0 commit comments

Comments
 (0)