From 56fe4448d3c64f57ec91265e4c8da7f5e9c03999 Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Wed, 4 May 2011 23:15:58 +0200 Subject: [PATCH] Switch back to running tests for one backend only This seems to cause unpredictable failures with pastebin (at least). Tests will have the backends attribute if they really want to tests all backends at once. For now, one backend is chosen for each run (and since tests are ran often, it will cover all backends eventually.) The backend instance name is displayed to ease the debugging. --- weboob/tools/test.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/weboob/tools/test.py b/weboob/tools/test.py index 3733894c..98ac20b6 100644 --- a/weboob/tools/test.py +++ b/weboob/tools/test.py @@ -18,6 +18,8 @@ # along with weboob. If not, see . from unittest import TestCase +from random import choice + from nose.plugins.skip import SkipTest from weboob.core import Weboob @@ -30,14 +32,17 @@ class BackendTest(TestCase): def __init__(self, *args, **kwargs): TestCase.__init__(self, *args, **kwargs) - self.backend = None + self.backends = {} self.backend_instance = None + self.backend = None self.weboob = Weboob() if self.weboob.load_backends(modules=[self.BACKEND]): + # provide the tests with all available backends self.backends = self.weboob.backend_instances - else: - self.backends = {} + # chose one backend (enough for most tests) + self.backend_instance = choice(self.backends.keys()) + self.backend = self.backends[self.backend_instance] def run(self, result): """ @@ -49,11 +54,7 @@ class BackendTest(TestCase): result.startTest(self) result.stopTest(self) raise SkipTest() - - for backend_instance, backend in self.backends.iteritems(): - self.backend = backend - self.backend_instance = backend_instance - TestCase.run(self, result) + TestCase.run(self, result) finally: self.weboob.deinit()