aleph-im / aleph-docs

Aleph.im Official Documentation (Work in progress)
https://docs.aleph.im/
MIT License
6 stars 8 forks source link

Fix: Impossible to ensure that every block of python code works #74

Closed Antonyjin closed 3 months ago

Antonyjin commented 3 months ago

We've given users plenty of examples so they can try out different functions on their own. The problem is that we may have written some code that doesn't work at all.

Solution: use mktestdocs to test blocks of python code I wrote a file located in /docs/test/ named python_test.py The script will go to the destination path I've specified and test every block of code that starts with '''python. This also means that if I've written code in python but it's not intended to be executed, it's possible to put only '''py, so that the code looks nice and well-formed but is not tested by mktestdocs.

To test locally, use the command below in /docs/test: pytest python_test.py::test_run_python_code

TO DO: Create a github action to test before building the documentation.

github-actions[bot] commented 3 months ago

Deployed (not pinned) on:

hoh commented 3 months ago

I tried to launch this with pytest, the test was skipped with the following message:

(aleph-docs) pytest -vv
=============================================================================================================================== test session starts ================================================================================================================================
platform linux -- Python 3.11.8, pytest-8.0.2, pluggy-1.4.0 -- /opt/venv/aleph-docs/bin/python
cachedir: .pytest_cache
rootdir: /home/sepal/Repos/aleph-im/aleph-docs
collected 1 item                                                                                                                                                                                                                                                                   

docs/test/python_test.py::test_run_python_code[NotSetType.token] SKIPPED (got empty parameter set ['fpath'], function test_run_python_code at /home/sepal/Repos/aleph-im/aleph-docs/docs/test/python_test.py:5)      
hoh commented 3 months ago

Why put the tests in the /docs directory ?

Antonyjin commented 3 months ago

I tried to launch this with pytest, the test was skipped with the following message:

(aleph-docs) pytest -vv
=============================================================================================================================== test session starts ================================================================================================================================
platform linux -- Python 3.11.8, pytest-8.0.2, pluggy-1.4.0 -- /opt/venv/aleph-docs/bin/python
cachedir: .pytest_cache
rootdir: /home/sepal/Repos/aleph-im/aleph-docs
collected 1 item                                                                                                                                                                                                                                                                   

docs/test/python_test.py::test_run_python_code[NotSetType.token] SKIPPED (got empty parameter set ['fpath'], function test_run_python_code at /home/sepal/Repos/aleph-im/aleph-docs/docs/test/python_test.py:5)      

You have to be inside the directory and then run the pytest command

Antonyjin commented 3 months ago

Why put the tests in the /docs directory ?

I put it there because I thought that these tests were part of the documentation tests but indeed on looking again, it's true that I find it more relevant to just put it at the root.

github-actions[bot] commented 3 months ago

Deployed (not pinned) on:

github-actions[bot] commented 3 months ago

Deployed (not pinned) on:

github-actions[bot] commented 3 months ago

Deployed (not pinned) on:

github-actions[bot] commented 3 months ago

Deployed (not pinned) on:

hoh commented 3 months ago

This is lacking one thing (that may need to be updated once https://github.com/aleph-im/aleph-docs/pull/79) : it does not actually run pytest in the CI.

github-actions[bot] commented 3 months ago

Deployed (not pinned) on:

github-actions[bot] commented 3 months ago

Deployed (not pinned) on:

github-actions[bot] commented 3 months ago

Deployed (not pinned) on:

hoh commented 3 months ago

See my suggestions on top of this branch: https://github.com/aleph-im/aleph-docs/pull/81

github-actions[bot] commented 3 months ago

Deployed (not pinned) on:

github-actions[bot] commented 3 months ago

Deployed (not pinned) on:

github-actions[bot] commented 3 months ago

Deployed (not pinned) on:

github-actions[bot] commented 3 months ago

Deployed (not pinned) on:

github-actions[bot] commented 3 months ago

Deployed (not pinned) on: