From 2d5ba154ed93f80569906051d9abd562fdc949b5 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Sat, 1 Sep 2012 13:33:41 +0200 Subject: [PATCH] Switch to module imports and with assertRaises in init_test. --- tests/utils/init_test.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/utils/init_test.py b/tests/utils/init_test.py index 2097e3e6..f232e2ef 100644 --- a/tests/utils/init_test.py +++ b/tests/utils/init_test.py @@ -1,24 +1,27 @@ -from mopidy.utils import get_class +from mopidy import utils from tests import unittest class GetClassTest(unittest.TestCase): def test_loading_module_that_does_not_exist(self): - self.assertRaises(ImportError, get_class, 'foo.bar.Baz') + with self.assertRaises(ImportError): + utils.get_class('foo.bar.Baz') def test_loading_class_that_does_not_exist(self): - self.assertRaises(ImportError, get_class, 'unittest.FooBarBaz') + with self.assertRaises(ImportError): + utils.get_class('unittest.FooBarBaz') def test_loading_incorrect_class_path(self): - self.assertRaises(ImportError, get_class, 'foobarbaz') + with self.assertRaises(ImportError): + utils.get_class('foobarbaz') def test_import_error_message_contains_complete_class_path(self): try: - get_class('foo.bar.Baz') + utils.get_class('foo.bar.Baz') except ImportError as e: self.assert_('foo.bar.Baz' in str(e)) def test_loading_existing_class(self): - cls = get_class('unittest.TestCase') + cls = utils.get_class('unittest.TestCase') self.assertEqual(cls.__name__, 'TestCase')