Is there some way (using the standard Django.test.TestCase framework) to perform a global initialization of certain variables, so that it only happens once.
Putting things setUp() makes it so that the variables are initialized before each test, which kills performance when the setup involves expensive operations. I'd like to run a setup type feature once, and then have the variables initialized here be visible to all my tests.
I'd prefer not to rewrite the test runner framework.
I am thinking of something similar to a before(:all) in the Ruby/RSpec world.
-S
This is partially addressed in newer versions of python/django by setUpClass() which will at least allow me to run class level setup.
You don't need to "re-write the whole test runner framework" but you will need to create a custom test_runner (you can just copy the existing one and modify it to include your global setup code). It's about 100 lines of code. Then set the TEST_RUNNER setting to point to your custom runner and away you go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With