Skip to content

Commit

Permalink
Merge pull request #255 from Crypto-TII/docs/add-doctests-documentation
Browse files Browse the repository at this point in the history
Docs/add doctests documentation
  • Loading branch information
peacker authored Jul 9, 2024
2 parents c2f4f1a + 7ee302f commit 01e54cf
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ To contribute to this project, please, follow the following conventions.
- [Single underscore VS double underscore](#single-underscore-vs-double-underscore)
- [C code](#c-code)
- [Testing](#testing)
- [Running tests](#running-tests)
- [Creating pytests](#creating-pytests)
- [Running pytests](#running-pytests)
- [Running doctests](#running-doctests)
- [Deprecation warnings](#deprecation-warnings)
- [Code analysis with SonarCloud](#code-analysis-with-sonarcloud)
- [Project overview](#project-overview)
Expand Down Expand Up @@ -647,6 +649,7 @@ children.
[C implementation of Python](https://peps.python.org/pep-0007/).

# Testing
## Creating pytests
The project uses **`Pytest` as it’s testing framework**. We can forget to write the example Docstrings as they will
still be part of the documentation.
Our tests are stored in the `tests` folder that mimics the folder structure of `claasp`.
Expand Down Expand Up @@ -688,8 +691,8 @@ def test_aes_block_cipher():
As you can see above, the `assert` keyword is the one that will check if our result is the one we expected.
Apart from that, the structure of the test is very similar.

## Running tests
To run all the project test you can run `make pytest command`, but if you want to run specific things you can do:
## Running pytests
To run all the project test you can run `make pytest` command, but if you want to run specific things you can do:
- **Run specific file:**
```bash
pytest -v tests/cipher_test.py
Expand Down Expand Up @@ -722,6 +725,18 @@ def test_aes_block_cipher():
ciphertext = 0x3ad77bb40d7a3660a89ecaf32466ef97
assert aes.evaluate([key, plaintext]) == ciphertext
```
## Running doctests
If you want to run all doctests you need to execute `make test` command.

If you want to execute a **specific module** you can execute:
```bash
sage -t claasp
```

And if you want to execute a **specific file test** you can execute:
```bash
sage -t claasp/cipher.py
```

## Deprecation warnings
We might get sometime deprecation warnings. To avoid them we can import `pytest` to the top of the file and add this
Expand Down

0 comments on commit 01e54cf

Please sign in to comment.