I'm using PyDev and testing with nose. Is there a way I can set an environment variable inside of PyDev only when I run unit tests?

thanks

有帮助吗?

解决方案

Moving my comments into a proper answer: As nose supports multiple levels of test fixtures, even package-level, and even without nose unittest.TestCase supports setUp() and tearDown() methods (and starting with Python 3.2, setUpClass() and tearDownClass() as class methods, as well as the module-level setUpModule() and tearDownModule()), it's easy to perform common initialization and post-testing operations such as setting environment variables, etc. without having to place the necessary code within each test function or even having to explicitly call the test fixture functions.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top