[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#754143: Fix the tests to not pollute the data directory



Hi Christophe,

On Wed, 09 Jul 2014, Christophe Siraut wrote:
> Please review the attached patch.

Thanks for the patch but I don't believe that you're following the correct
approach here.

First, tests should work and behave correctly even without the settings in
project/settings/test.py. This file is just a convenience to improve some
aspects of the test runs, it should not be mandatory.

Then using a fixed name in /tmp/ is not acceptable either, it's a security
issue. And obviously not cleaning up is also a problem, subsquent test
could be polluted by the data of former tries...

I'm not sure what's the best approach but I see two clean solutions:

- something global implemented as a derivative class of TestCase that
  does the required directory creation and settings change in self.setUp
  and drops the directory with a function recorded with self.addCleanup

- something more local with a class/method decorator that does the same
  (in the spirit of distro_tracker.core.tests.common.temporary_media_dir)

> +# Note TestCase does not reset the cache yet,
> +# see https://code.djangoproject.com/ticket/11505

Good point, but I don't think we're using a cache yet.

Cheers,
-- 
Raphaël Hertzog ◈ Debian Developer

Discover the Debian Administrator's Handbook:
→ http://debian-handbook.info/get/


Reply to: