Pytest code in jupyter

I can execute a pytest command using a custom virtual environment. I have tried running the entire python script using pytest and that works but I want to be able to run the python code as blocks (by picking selective snippets) in jupyter. The code runs using pytest command. Would this work

For running snippets, have you read and tried what I outline in Feature Request - Ability to Split and Independently Execute Sections of a Single Cell - #2 by fomightez ?

pytest works with Jupyter otherwise and so I think this will work. However, without examples (which can be toy examples) and specifics it is hard to guide you further.

See also:

2 Likes

Thank you for the reply, I am trying to run the code in the cells now but I am hitting import issues.
To run the script normally I just set few environment variables and source a custom environment before running the pytest command.
When I tried to follow the same approach in jupyter which is set env variables and activate a virtual env(by running a shell script) and then try to just run the imports, I ran into a bunch of import errors which are getting difficult to solve.
Any help here would be appreciated, thank you

As I said in my post, without specifics we cannot offer much help,