سؤال

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