ZakBibi / PracticePython

A repository of my practice python projects.
0 stars 0 forks source link

Make slow postgres unittests run faster. #113

Closed BasilBibi closed 5 years ago

BasilBibi commented 5 years ago

Instead of using setUp() and tearDown() which run before and after each and every test case, use setUpClass() and tearDownClass() as these only run once per test class.

You can then access dao using type(self).dao

https://stackoverflow.com/questions/25577578/python-access-class-variable-from-instance/25577642#25577642

BasilBibi commented 5 years ago

I changed OrderPostgresDaoTests and they ran in 7 passed in 2.67 seconds