From 8d8b752237221621af68ec44a3cd97190491a3d3 Mon Sep 17 00:00:00 2001 From: Alexis Lee Date: Mon, 2 Mar 2015 16:08:40 +0000 Subject: [PATCH] Remove TranslationFixture It doesn't work and keeping the code obscures that. When tox starts up, it seems to import all tests. Many of these import modules from real Nova. As soon as something imports nova.i18n, the short translators (_, _LI etc) are produced using oslo_i18n. These short translators are then imported directly into the namespace of each module, making them nearly impossible to mock. We could monkeypatch oslo_i18n.TranslatorFactory._make_translation_func, but I don't know a reliable way to do that before any test has imported nova.i18n without touching every test. Change-Id: Idcc4409edae5ddfa0a1c2052a746d6412dda24ac --- nova/test.py | 1 - nova/tests/fixtures.py | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/nova/test.py b/nova/test.py index b82506db0bd3..6698d0e551fb 100644 --- a/nova/test.py +++ b/nova/test.py @@ -193,7 +193,6 @@ class TestCase(testtools.TestCase): self.useFixture(fixtures.NestedTempfile()) self.useFixture(fixtures.TempHomeDir()) - self.useFixture(nova_fixtures.TranslationFixture()) self.useFixture(log_fixture.get_logging_handle_error_fixture()) self.useFixture(nova_fixtures.OutputStreamCapture()) diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index c630bb74c57b..f1ae8ea32a2c 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -17,7 +17,6 @@ """Fixtures for Nova tests.""" from __future__ import absolute_import -import gettext import logging as std_logging import os import uuid @@ -56,17 +55,6 @@ class ServiceFixture(fixtures.Fixture): self.addCleanup(self.service.kill) -class TranslationFixture(fixtures.Fixture): - """Use gettext NullTranslation objects in tests.""" - - def setUp(self): - super(TranslationFixture, self).setUp() - nulltrans = gettext.NullTranslations() - gettext_fixture = fixtures.MonkeyPatch('gettext.translation', - lambda *x, **y: nulltrans) - self.gettext_patcher = self.useFixture(gettext_fixture) - - class NullHandler(std_logging.Handler): """custom default NullHandler to attempt to format the record.