Create virtual environments to run the Django app (assumes python --version prints Python 2.7.17):
virtualenv .venv-py2virtualenv -p python3 .venv-py3
Activate one of them
In VSCode, it may be necessary to
cmd+shift+p,Python: Select interpreterto set the correct venv for the debugger.
source .venv-py3/bin/activate
Install dependencies. Leave Django out of requirements and explicitly install it, so that we can easily test across multiple versions.
pip install -r requirements.txt django==3.2.12pip install -r requirements-docs.txt
python ./manage.py test
coverage run --source djraphql -m pytest
coverage report -m
Nearly all unit-tests reside in the sample_music_app app, under the tests folder. This allows for directly testing the API generated by DjraphQL by building a schema based on the Django models defined in app.
Low-level unit-tests that make assumptions about implementation are not encouraged. Rather, write surface-level unit-tests that exercise a specific feature, behavior, or bug being fixed. This allows us to confidently and more easily refactor the underlying implementation without the burden of unnecessarily broken tests.
pip install autoflakeautoflake --in-place --remove-all-unused-imports --ignore-init-module-imports ./**/*.py
See tutorial here.
pip install --user --upgrade setuptools wheel twine
- In
setup.py, update theVERSIONnumber
python setup.py sdist bdist_wheel
twine upload dist/djraphql-x.x.x.tar.gz- Enter
__token__for the user, then a valid PyPi token as the password
- Enter
pip install -r requirements-docs.txtcd docsrc && make html