From 3d73cd2fd3a5bfdf91ad032f4453b4fe1bee7d29 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 May 2013 16:36:20 +0200 Subject: [PATCH] better debugging for wrong type, fix emulator tests, fixes #176 Signed-off-by: Nico Schottelius --- cdist/emulator.py | 7 ++++++- cdist/test/emulator/__init__.py | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cdist/emulator.py b/cdist/emulator.py index a9c760cb..5a23fca5 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -184,7 +184,12 @@ class Emulator(object): if len(requirement) == 0: continue # Raises an error, if object cannot be created - cdist_object = self.cdist_object.object_from_name(requirement) + try: + cdist_object = self.cdist_object.object_from_name(requirement) + except core.cdist_type.NoSuchTypeError: + self.log.error("%s requires object %s with non-existing type at %s" % (self.cdist_object.name, requirement, self.object_source)) + raise + self.log.debug("Recording requirement: " + requirement) diff --git a/cdist/test/emulator/__init__.py b/cdist/test/emulator/__init__.py index fc0b6695..a9746f99 100644 --- a/cdist/test/emulator/__init__.py +++ b/cdist/test/emulator/__init__.py @@ -63,13 +63,13 @@ class EmulatorTestCase(test.CdistTestCase): def test_nonexistent_type_exec(self): argv = ['__does-not-exist'] - self.assertRaises(core.NoSuchTypeError, emulator.Emulator, argv, env=self.env) + self.assertRaises(core.cdist_type.NoSuchTypeError, emulator.Emulator, argv, env=self.env) def test_nonexistent_type_requirement(self): argv = ['__file', '/tmp/foobar'] self.env['require'] = '__does-not-exist/some-id' emu = emulator.Emulator(argv, env=self.env) - self.assertRaises(core.NoSuchTypeError, emu.run) + self.assertRaises(core.cdist_type.NoSuchTypeError, emu.run) def test_illegal_object_id_requirement(self): argv = ['__file', '/tmp/foobar'] @@ -81,7 +81,7 @@ class EmulatorTestCase(test.CdistTestCase): argv = ['__file', '/tmp/foobar'] self.env['require'] = '__file' emu = emulator.Emulator(argv, env=self.env) - self.assertRaises(core.IllegalObjectIdError, emu.run) + self.assertRaises(core.cdist_object.MissingObjectIdError, emu.run) def test_singleton_object_requirement(self): argv = ['__file', '/tmp/foobar']