def test_require_module_good(self): """ should return the same function """ def func() : pass module = 'sys' decorator = require_module(module) self.assertEqual(func, decorator(func), 'module %s exists : function \ return by the decorator should be the same.' % module)
def test_require_module_good(self): """ should return the same function """ def func() : pass module = 'sys' decorator = require_module(module) self.assertEquals(func, decorator(func), 'module %s exists : function \ return by the decorator should be the same.' % module)
def test_require_module_bad(self): """ should return a different function : skipping test """ def func() : pass modules = ('bla', 'blo', 'bli') for module in modules: try: __import__(module) pass except ImportError: decorator = require_module(module) self.assertNotEqual(func, decorator(func), 'module %s does \ not exist : function return by the decorator should \ NOT be the same.' % module) return print 'all modules in %s exist. Could not test %s' % (', '.join(modules), sys._getframe().f_code.co_name)
def test_require_module_bad(self): """ should return a different function : skipping test """ def func() : pass modules = ('bla', 'blo', 'bli') for module in modules: try: __import__(module) pass except ImportError: decorator = require_module(module) self.assertNotEquals(func, decorator(func), 'module %s does \ not exist : function return by the decorator should \ NOT be the same.' % module) return print 'all modules in %s exist. Could not test %s' % (', '.join(modules), sys._getframe().f_code.co_name)