poetry new <project-name>
poetry add <library>
poetry remove <library>
poetry update <library>
poetry run which python
poetry run python app.py
poetry run python -m unittest discover
poetry show
1 - Edit pyproject.toml
:
[tool.poetry.scripts]
test = 'scripts:test'
2 - Create a scripts.py
file on the root directory of your project:
import subprocess
def test():
"""
Run all unittests. Equivalent to:
`poetry run python -u -m unittest discover`
"""
subprocess.run(
['python', '-u', '-m', 'unittest', 'discover']
)
3 - Run script:
poetry run test
poetry config virtualenvs.create false
poetry config --list