I am using LiClipse / PyDev. When I run some test or other python module from the package explorer via right click -> run as -> python run, the working directory is set to the directory of the corresponding file, e.g. ${workspace_loc:MyProject/tests/misc}.
I want everything to be executed from the root folder of the project though. Under run configurations -> arguments, that folder can be selected via the button "default" which sets the working directory to ${project_loc:/selected project name}. Unfortunately the "default" button apparently is not selected by default, but instead the "other" option with the directory set as described above.
When having many test modules it becomes a little bit annoying to select this "default" button manually for each one. So how do I get LiClipse to actually select that button by default? Or to use the project directory as the working directory by default in some other way?
A similar question was already asked before, but without a satisfying answer: Configuring the working directory in Eclipse 3.8.1 with PyDev-project. The only conclusion was that an Eclipse bug does not allow to configure the value of the default option, which is not necessary for my purpose though. I only want this option to actually be selected.
The issue might be specific to PyDev, as it seems that Eclipse usually has the "default" option selected according to what I read.
Well, unfortunately, as you discovered, there's really no way to set that default in the IDE.
Still, to solve your problem related to tests, my suggestion would be using the pytest runner (you may have to install it -- instructions at: https://pytest.org/latest/getting-started.html and then set in the PyDev > PyUnit preferences the setting to use the pytest runner)... as a note, even if you won't be using the pytest way of writing tests (which I highly recommend), and using unittest.TestCase, it should work...
When running pytest, PyDev needs to follow a different logic because of how it deals and loads its fixtures which make it use always the same folder (I think it's the source folder, but if you're using the source folder and the project folder as the same it should work -- and if that's not the case, in pytest, it's trivial to create a session auto-use fixture which you could use to change the working directory to a given folder (with unittest.TestCase this is more difficult to do as you're constrained through your test class hierarchy, but you could also override the setUp of your tests to do that).