[Python] running a package pytest with poetry

Discussão em 'Python' iniciado por Stack, Maio 16, 2025.

  1. Stack

    Stack Membro Participativo

    I am new to poetry and want to get it set-up with pytest. I have a package mylib in the following set-up

    ├── dist
    │ ├── mylib-0.0.1-py3-none-any.whl
    │ └── mylib-0.0.1.tar.gz
    ├── poetry.lock
    ├── mylib
    │ ├── functions.py
    │ ├── __init__.py
    │ └── utils.py
    ├── pyproject.toml
    ├── README.md
    └── tests
    └── test_functions.py


    in test_functions I have

    import mylib


    However, when I run

    poetry run pytest


    it complains about mylib not being included. I can run

    pip install dist/mylib-0.0.1-py3-none-any.whl


    but that clutters my python environment with mylib. I want to use that environment as well for other packages.

    My question is: What is the proper way to work with poetry and pytest?

    My underlying python environment is a clean pyenv python 3.8. Using pyproject.toml I create a project based virtual environment for mylib.

    Continue reading...

Compartilhe esta Página