How to run tests of python library without compiling the whole library

I’m packaging a library, and some test fails. I’d like to run the tests manually to see what is the problem, but unfortunately I can’t find how to run the test phase without recompiling the whole library. For now, I’m simply doing, in the nixpkgs folder:

nix-build -A python38.mylibrary

Is there a way to run only the tests and cache the compilation step? Is it possible to have access to a shell, and be left right before the test runs? I tried to do:

nix-shell -A python38.mylibrary

but then when I try to run the test phase I get lot’s of errors like E NameError: name '__IPYTHON__' is not defined or AttributeError: partially initialized module 'mylibrary' has no attribute 'settings' (most likely due to a circular import) which I usually don’t have on regular tests.


Try breakpointHook. It will pause the build at the failure point, and allow you to shell into the build environment to debug it.

Great, thanks a lot, good to know!