You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I've been trying to use pytest-virtualenv, but I've been running into some issues. One is the known issue with pip install . (#163). The other is a nasty data loss bug when using an explicit workspace:
I have a directory in which I have a very simple test suite. I am trying to test running that test suite via an external program similar to coverage. With coverage, one can do coverage run -m unittest, and I'm trying to implement a similar tool.
In my main test suite I'm trying to do something like:
deftest_run_unittest_suite(virtualenv):
virtualenv.install_package("my_package")
result=virtualenv.run("my_package run -m unittest", capture=True)
... # assert some things
The first issue I ran into is that I need to run from the same directory as the example test suite. I can do this with VirtualEnv(workspace="project-dir"):
frompytest_virtualenvimportVirtualEnvdeftest_run_unittest_suite():
virtualenv=VirtualEnv(workspace="project-dir")
# virtualenv.install_package("my_package") # skip trying to install for now# Use python -m unittest instead as a starting pointresult=virtualenv.run("python -m unittest", capture=True)
...
This works, for one test run, but deletes project-dir when cleaning up virtualenv. As you might be able to imagine, this really confused me for a while, until I figured out what was going on. Thankfully, the code in my project-dir was easy enough to re-create.
I also suggest changing the default behaviour when workspace is explicitly provided to delete=False. delete=True when the workspace is truly temporary is great, but when the workspace is persistent it's a nasty trap for the unwary.
The text was updated successfully, but these errors were encountered:
Hi there - thanks for raising! Agreed this is surprising behaviour, your suggestion of exposing the delete parameter is a good one, same for defaulting it to False when a workspace is provided.
Hi! I've been trying to use
pytest-virtualenv
, but I've been running into some issues. One is the known issue withpip install .
(#163). The other is a nasty data loss bug when using an explicit workspace:I have a directory in which I have a very simple test suite. I am trying to test running that test suite via an external program similar to
coverage
. With coverage, one can docoverage run -m unittest
, and I'm trying to implement a similar tool.In my main test suite I'm trying to do something like:
The first issue I ran into is that I need to run from the same directory as the example test suite. I can do this with
VirtualEnv(workspace="project-dir")
:This works, for one test run, but deletes
project-dir
when cleaning upvirtualenv
. As you might be able to imagine, this really confused me for a while, until I figured out what was going on. Thankfully, the code in myproject-dir
was easy enough to re-create.As a workaround, I discovered that I can do:
However, I think this would be better fixed here.
The first fix I recommend is exposing the
delete
parameter fromWorkspace
inVirtualEnv
:I also suggest changing the default behaviour when
workspace
is explicitly provided todelete=False
.delete=True
when the workspace is truly temporary is great, but when the workspace is persistent it's a nasty trap for the unwary.The text was updated successfully, but these errors were encountered: