diff options
-rw-r--r-- | tests/base.py | 15 | ||||
-rw-r--r-- | tests/builder/test_builder.py | 5 | ||||
-rw-r--r-- | tests/builders/test_builders.py | 2 | ||||
-rw-r--r-- | tests/cachestorage/test_cachestorage.py | 3 | ||||
-rw-r--r-- | tests/cmd/test_cmd.py | 3 | ||||
-rw-r--r-- | tests/duplicates/test_duplicates.py | 4 | ||||
-rw-r--r-- | tests/errors/test_exceptions.py | 5 | ||||
-rw-r--r-- | tests/general/test_general.py | 2 | ||||
-rw-r--r-- | tests/hipchat/test_hipchat.py | 2 | ||||
-rw-r--r-- | tests/jsonparser/test_jsonparser.py | 4 | ||||
-rw-r--r-- | tests/localyaml/test_localyaml.py | 7 | ||||
-rw-r--r-- | tests/macros/test_macros.py | 2 | ||||
-rw-r--r-- | tests/moduleregistry/test_moduleregistry.py | 2 | ||||
-rw-r--r-- | tests/notifications/test_notifications.py | 2 | ||||
-rw-r--r-- | tests/parameters/test_parameters.py | 2 | ||||
-rw-r--r-- | tests/properties/test_properties.py | 2 | ||||
-rw-r--r-- | tests/publishers/test_publishers.py | 2 | ||||
-rw-r--r-- | tests/reporters/test_reporters.py | 2 | ||||
-rw-r--r-- | tests/scm/test_scm.py | 2 | ||||
-rw-r--r-- | tests/triggers/test_triggers.py | 2 | ||||
-rw-r--r-- | tests/wrappers/test_wrappers.py | 2 | ||||
-rw-r--r-- | tests/yamlparser/test_yamlparser.py | 4 |
22 files changed, 45 insertions, 31 deletions
diff --git a/tests/base.py b/tests/base.py index 5b9f0746..662a1170 100644 --- a/tests/base.py +++ b/tests/base.py @@ -18,10 +18,11 @@ # under the License. import io -import logging import os import re import doctest +import logging +import fixtures import json import operator import testtools @@ -96,7 +97,15 @@ def get_scenarios(fixtures_path, in_ext='yaml', out_ext='xml', return scenarios -class BaseTestCase(object): +class LoggingFixture(object): + + def setUp(self): + + super(LoggingFixture, self).setUp() + self.useFixture(fixtures.FakeLogger(level=logging.DEBUG)) + + +class BaseTestCase(LoggingFixture): scenarios = [] fixtures_path = None @@ -104,8 +113,6 @@ class BaseTestCase(object): maxDiff = None # always dump text difference longMessage = True # keep normal error message when providing our - logging.basicConfig() - def _read_utf8_content(self): # if None assume empty file if self.out_filename is None: diff --git a/tests/builder/test_builder.py b/tests/builder/test_builder.py index 34cddced..c6b5ed11 100644 --- a/tests/builder/test_builder.py +++ b/tests/builder/test_builder.py @@ -16,19 +16,20 @@ import jenkins_jobs.builder +from tests.base import LoggingFixture from tests.base import mock from testtools import TestCase @mock.patch('jenkins_jobs.builder.CacheStorage', mock.MagicMock) -class TestCaseTestBuilder(TestCase): +class TestCaseTestBuilder(LoggingFixture, TestCase): def setUp(self): + super(TestCaseTestBuilder, self).setUp() self.builder = jenkins_jobs.builder.Builder( 'http://jenkins.example.com', 'doesnot', 'matter', plugins_list=['plugin1', 'plugin2'], ) - TestCase.setUp(self) def test_plugins_list(self): self.assertEqual(self.builder.plugins_list, ['plugin1', 'plugin2']) diff --git a/tests/builders/test_builders.py b/tests/builders/test_builders.py index fa5115bf..6ec961ef 100644 --- a/tests/builders/test_builders.py +++ b/tests/builders/test_builders.py @@ -22,7 +22,7 @@ from jenkins_jobs.modules import builders from tests.base import get_scenarios, BaseTestCase -class TestCaseModuleBuilders(TestWithScenarios, TestCase, BaseTestCase): +class TestCaseModuleBuilders(TestWithScenarios, BaseTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path) klass = builders.Builders diff --git a/tests/cachestorage/test_cachestorage.py b/tests/cachestorage/test_cachestorage.py index c82244b5..f1b3f69c 100644 --- a/tests/cachestorage/test_cachestorage.py +++ b/tests/cachestorage/test_cachestorage.py @@ -17,10 +17,11 @@ import os import testtools import jenkins_jobs +from tests.base import LoggingFixture from tests.base import mock -class TestCaseCacheStorage(testtools.TestCase): +class TestCaseCacheStorage(LoggingFixture, testtools.TestCase): @mock.patch('jenkins_jobs.builder.CacheStorage.get_cache_dir', lambda x: '/bad/file') diff --git a/tests/cmd/test_cmd.py b/tests/cmd/test_cmd.py index 04846942..610b546e 100644 --- a/tests/cmd/test_cmd.py +++ b/tests/cmd/test_cmd.py @@ -2,10 +2,11 @@ import os from six.moves import configparser, StringIO import testtools from jenkins_jobs import cmd +from tests.base import LoggingFixture from tests.base import mock -class CmdTestsBase(testtools.TestCase): +class CmdTestsBase(LoggingFixture, testtools.TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') parser = cmd.create_parser() diff --git a/tests/duplicates/test_duplicates.py b/tests/duplicates/test_duplicates.py index e7e05e97..74edc6c4 100644 --- a/tests/duplicates/test_duplicates.py +++ b/tests/duplicates/test_duplicates.py @@ -24,8 +24,8 @@ from tests.base import get_scenarios from tests.base import mock -class TestCaseModuleDuplicates(TestWithScenarios, TestCase, - SingleJobTestCase): +class TestCaseModuleDuplicates(TestWithScenarios, + SingleJobTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path) diff --git a/tests/errors/test_exceptions.py b/tests/errors/test_exceptions.py index 74e7b194..f4b2dff4 100644 --- a/tests/errors/test_exceptions.py +++ b/tests/errors/test_exceptions.py @@ -1,6 +1,7 @@ from testtools import ExpectedException, TestCase from jenkins_jobs import errors +from tests.base import LoggingFixture def dispatch(exc, *args): @@ -20,7 +21,7 @@ def gen_xml(exc, *args): raise exc(*args) -class TestInvalidAttributeError(TestCase): +class TestInvalidAttributeError(LoggingFixture, TestCase): def test_no_valid_values(self): # When given no valid values, InvalidAttributeError simply displays a @@ -47,7 +48,7 @@ class TestInvalidAttributeError(TestCase): valid_values) -class TestMissingAttributeError(TestCase): +class TestMissingAttributeError(LoggingFixture, TestCase): def test_with_single_missing_attribute(self): # When passed a single missing attribute, display a message indicating diff --git a/tests/general/test_general.py b/tests/general/test_general.py index 17c31c2e..dc7d9698 100644 --- a/tests/general/test_general.py +++ b/tests/general/test_general.py @@ -22,7 +22,7 @@ from jenkins_jobs.modules import general from tests.base import get_scenarios, BaseTestCase -class TestCaseModuleGeneral(TestWithScenarios, TestCase, BaseTestCase): +class TestCaseModuleGeneral(TestWithScenarios, BaseTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path) klass = general.General diff --git a/tests/hipchat/test_hipchat.py b/tests/hipchat/test_hipchat.py index 13d38626..a3b4355a 100644 --- a/tests/hipchat/test_hipchat.py +++ b/tests/hipchat/test_hipchat.py @@ -19,7 +19,7 @@ from jenkins_jobs.modules import hipchat_notif from tests.base import get_scenarios, BaseTestCase -class TestCaseModulePublishers(TestWithScenarios, TestCase, BaseTestCase): +class TestCaseModulePublishers(TestWithScenarios, BaseTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path) klass = hipchat_notif.HipChat diff --git a/tests/jsonparser/test_jsonparser.py b/tests/jsonparser/test_jsonparser.py index 7b55e0a7..776549c4 100644 --- a/tests/jsonparser/test_jsonparser.py +++ b/tests/jsonparser/test_jsonparser.py @@ -21,7 +21,7 @@ from testscenarios.testcase import TestWithScenarios from tests.base import get_scenarios, SingleJobTestCase -class TestCaseModuleJsonParser(TestWithScenarios, TestCase, - SingleJobTestCase): +class TestCaseModuleJsonParser(TestWithScenarios, + SingleJobTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path, in_ext='json', out_ext='xml') diff --git a/tests/localyaml/test_localyaml.py b/tests/localyaml/test_localyaml.py index 7699db71..972bbe54 100644 --- a/tests/localyaml/test_localyaml.py +++ b/tests/localyaml/test_localyaml.py @@ -22,13 +22,14 @@ from yaml.composer import ComposerError from jenkins_jobs import builder from tests.base import get_scenarios, JsonTestCase, YamlTestCase +from tests.base import LoggingFixture def _exclude_scenarios(input_filename): return os.path.basename(input_filename).startswith("custom_") -class TestCaseLocalYamlInclude(TestWithScenarios, TestCase, JsonTestCase): +class TestCaseLocalYamlInclude(TestWithScenarios, JsonTestCase, TestCase): """ Verify application specific tags independently of any changes to modules XML parsing behaviour @@ -47,7 +48,7 @@ class TestCaseLocalYamlInclude(TestWithScenarios, TestCase, JsonTestCase): super(TestCaseLocalYamlInclude, self).test_yaml_snippet() -class TestCaseLocalYamlAnchorAlias(TestWithScenarios, TestCase, YamlTestCase): +class TestCaseLocalYamlAnchorAlias(TestWithScenarios, YamlTestCase, TestCase): """ Verify yaml input is expanded to the expected yaml output when using yaml anchors and aliases. @@ -56,7 +57,7 @@ class TestCaseLocalYamlAnchorAlias(TestWithScenarios, TestCase, YamlTestCase): scenarios = get_scenarios(fixtures_path, 'iyaml', 'oyaml') -class TestCaseLocalYamlIncludeAnchors(TestCase): +class TestCaseLocalYamlIncludeAnchors(LoggingFixture, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') diff --git a/tests/macros/test_macros.py b/tests/macros/test_macros.py index 4023bb97..9fc8ef5c 100644 --- a/tests/macros/test_macros.py +++ b/tests/macros/test_macros.py @@ -21,6 +21,6 @@ from testscenarios.testcase import TestWithScenarios from tests.base import get_scenarios, SingleJobTestCase -class TestCaseModuleSCMMacro(TestWithScenarios, TestCase, SingleJobTestCase): +class TestCaseModuleSCMMacro(TestWithScenarios, SingleJobTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path) diff --git a/tests/moduleregistry/test_moduleregistry.py b/tests/moduleregistry/test_moduleregistry.py index fbe969c7..e95931ea 100644 --- a/tests/moduleregistry/test_moduleregistry.py +++ b/tests/moduleregistry/test_moduleregistry.py @@ -6,9 +6,11 @@ from six.moves import configparser, StringIO from jenkins_jobs import cmd from jenkins_jobs.registry import ModuleRegistry +from tests.base import LoggingFixture class ModuleRegistryPluginInfoTestsWithScenarios(TestWithScenarios, + LoggingFixture, tt.TestCase): scenarios = [ ('s1', dict(v1='1.0.0', op='__gt__', v2='0.8.0')), diff --git a/tests/notifications/test_notifications.py b/tests/notifications/test_notifications.py index 13fd32e4..ae077126 100644 --- a/tests/notifications/test_notifications.py +++ b/tests/notifications/test_notifications.py @@ -22,7 +22,7 @@ from jenkins_jobs.modules import notifications from tests.base import get_scenarios, BaseTestCase -class TestCaseModuleNotifications(TestWithScenarios, TestCase, BaseTestCase): +class TestCaseModuleNotifications(TestWithScenarios, BaseTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path) klass = notifications.Notifications diff --git a/tests/parameters/test_parameters.py b/tests/parameters/test_parameters.py index 11ff0f0e..a71049cc 100644 --- a/tests/parameters/test_parameters.py +++ b/tests/parameters/test_parameters.py @@ -22,7 +22,7 @@ from jenkins_jobs.modules import parameters from tests.base import get_scenarios, BaseTestCase -class TestCaseModuleParameters(TestWithScenarios, TestCase, BaseTestCase): +class TestCaseModuleParameters(TestWithScenarios, BaseTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path) klass = parameters.Parameters diff --git a/tests/properties/test_properties.py b/tests/properties/test_properties.py index f601601a..0a0fd2e9 100644 --- a/tests/properties/test_properties.py +++ b/tests/properties/test_properties.py @@ -22,7 +22,7 @@ from jenkins_jobs.modules import properties from tests.base import get_scenarios, BaseTestCase -class TestCaseModuleProperties(TestWithScenarios, TestCase, BaseTestCase): +class TestCaseModuleProperties(TestWithScenarios, BaseTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path) klass = properties.Properties diff --git a/tests/publishers/test_publishers.py b/tests/publishers/test_publishers.py index f35a9a78..c752f918 100644 --- a/tests/publishers/test_publishers.py +++ b/tests/publishers/test_publishers.py @@ -22,7 +22,7 @@ from jenkins_jobs.modules import publishers from tests.base import get_scenarios, BaseTestCase -class TestCaseModulePublishers(TestWithScenarios, TestCase, BaseTestCase): +class TestCaseModulePublishers(TestWithScenarios, BaseTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path) klass = publishers.Publishers diff --git a/tests/reporters/test_reporters.py b/tests/reporters/test_reporters.py index 497c538b..4297d6d4 100644 --- a/tests/reporters/test_reporters.py +++ b/tests/reporters/test_reporters.py @@ -21,7 +21,7 @@ from jenkins_jobs.modules import reporters from tests.base import get_scenarios, BaseTestCase -class TestCaseModuleReporters(TestWithScenarios, TestCase, BaseTestCase): +class TestCaseModuleReporters(TestWithScenarios, BaseTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path) klass = reporters.Reporters diff --git a/tests/scm/test_scm.py b/tests/scm/test_scm.py index 8125e83f..d61b99e2 100644 --- a/tests/scm/test_scm.py +++ b/tests/scm/test_scm.py @@ -22,7 +22,7 @@ from jenkins_jobs.modules import scm from tests.base import get_scenarios, BaseTestCase -class TestCaseModuleSCM(TestWithScenarios, TestCase, BaseTestCase): +class TestCaseModuleSCM(TestWithScenarios, BaseTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path) klass = scm.SCM diff --git a/tests/triggers/test_triggers.py b/tests/triggers/test_triggers.py index 553e67d5..543d2079 100644 --- a/tests/triggers/test_triggers.py +++ b/tests/triggers/test_triggers.py @@ -22,7 +22,7 @@ from jenkins_jobs.modules import triggers from tests.base import get_scenarios, BaseTestCase -class TestCaseModuleTriggers(TestWithScenarios, TestCase, BaseTestCase): +class TestCaseModuleTriggers(TestWithScenarios, BaseTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path) klass = triggers.Triggers diff --git a/tests/wrappers/test_wrappers.py b/tests/wrappers/test_wrappers.py index 5312fd38..26261e8e 100644 --- a/tests/wrappers/test_wrappers.py +++ b/tests/wrappers/test_wrappers.py @@ -22,7 +22,7 @@ from jenkins_jobs.modules import wrappers from tests.base import get_scenarios, BaseTestCase -class TestCaseModuleWrappers(TestWithScenarios, TestCase, BaseTestCase): +class TestCaseModuleWrappers(TestWithScenarios, BaseTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path) klass = wrappers.Wrappers diff --git a/tests/yamlparser/test_yamlparser.py b/tests/yamlparser/test_yamlparser.py index 99a345b5..415ed8cb 100644 --- a/tests/yamlparser/test_yamlparser.py +++ b/tests/yamlparser/test_yamlparser.py @@ -21,7 +21,7 @@ from testscenarios.testcase import TestWithScenarios from tests.base import get_scenarios, SingleJobTestCase -class TestCaseModuleYamlInclude(TestWithScenarios, TestCase, - SingleJobTestCase): +class TestCaseModuleYamlInclude(TestWithScenarios, + SingleJobTestCase, TestCase): fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures') scenarios = get_scenarios(fixtures_path) |