Added a better way to delete users. Catched the exception for perm_list.
[e_cidadania.git] / tests / nose_plugins.py
blobcdfdfd9e4a8294dfae151bc412d9e0fed7e60d6a
1 #/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 # Copyright (c) 2010-2012 Cidadania S. Coop. Galega
6 # This file is part of e-cidadania.
8 # e-cidadania is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # e-cidadania is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with e-cidadania. If not, see <http://www.gnu.org/licenses/>.
22 from nose.plugins import Plugin
24 from django.core import management
27 def flush_database():
28 """Flushes the default test database.
29 """
30 management.call_command('flush', verbosity=0, interactive=False)
33 class DatabaseFlushPlugin(Plugin):
34 """Nose plugin to flush the database after every test.
36 The instances of models generated in one test may cause other tests to fail.
37 So it is necessary to clear the test database after every test.
38 """
40 name = 'DatabaseFlushPlugin'
41 enabled = True
43 def options(self, parser, env):
44 return Plugin.options(self, parser, env)
46 def configure(self, parser, env):
47 Plugin.configure(self, parser, env)
48 self.enabled = True
50 def afterTest(self, test):
51 flush_database()