当前位置: 首页>>代码示例>>Python>>正文


Python unittest.skip方法代码示例

本文整理汇总了Python中unittest.skip方法的典型用法代码示例。如果您正苦于以下问题:Python unittest.skip方法的具体用法?Python unittest.skip怎么用?Python unittest.skip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest的用法示例。


在下文中一共展示了unittest.skip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_init_attributes

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def test_init_attributes(self):
        r"""Test of initialization and __init__ -- object attributes.

        Method: Ensure that the attributes special to RVTargetList are
        present and of the right length.
        """
        tlist = self.fixture
        self.basic_validation(tlist)
        # ensure the votable-derived star attributes are present
        #   these are set in __init__
        for att in tlist.atts_mapping:
            self.assertIn(att, tlist.__dict__)
            self.assertEqual(len(tlist.__dict__[att]), tlist.nStars)
        # ensure star attributes are present
        #   these attributes are set in populate_target_list
        for att in ['comp0', 'BC', 'L', 'MV', 'coords']:
            self.assertIn(att, tlist.__dict__)
            self.assertEqual(len(tlist.__dict__[att]), tlist.nStars)

    # @unittest.skip("Skipping init - attributes.") 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:22,代码来源:test_KnownRVPlanetsTargetList.py

示例2: test_str

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def test_str(self):
        r"""Test __str__ method, for full coverage."""
        tlist = self.fixture
        # replace stdout and keep a reference
        original_stdout = sys.stdout
        sys.stdout = StringIO()
        # call __str__ method
        result = tlist.__str__()
        # examine what was printed
        contents = sys.stdout.getvalue()
        self.assertEqual(type(contents), type(''))
        self.assertIn('PlanetPhysicalModel', contents)
        self.assertIn('PlanetPopulation', contents)
        self.assertIn('Completeness', contents)
        sys.stdout.close()
        # it also returns a string, which is not necessary
        self.assertEqual(type(result), type(''))
        # put stdout back
        sys.stdout = original_stdout

    # @unittest.skip("Skipping populate_target_list.") 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:23,代码来源:test_KnownRVPlanetsTargetList.py

示例3: test_class_not_setup_or_torndown_when_skipped

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def test_class_not_setup_or_torndown_when_skipped(self):
        class Test(unittest.TestCase):
            classSetUp = False
            tornDown = False
            @classmethod
            def setUpClass(cls):
                Test.classSetUp = True
            @classmethod
            def tearDownClass(cls):
                Test.tornDown = True
            def test_one(self):
                pass

        Test = unittest.skip("hop")(Test)
        self.runTests(Test)
        self.assertFalse(Test.classSetUp)
        self.assertFalse(Test.tornDown) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:19,代码来源:test_setups.py

示例4: test_skipping

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def test_skipping(self):
        class Foo(unittest.TestCase):
            def test_skip_me(self):
                self.skipTest("skip")
        events = []
        result = LoggingResult(events)
        test = Foo("test_skip_me")
        test.run(result)
        self.assertEqual(events, ['startTest', 'addSkip', 'stopTest'])
        self.assertEqual(result.skipped, [(test, "skip")])

        # Try letting setUp skip the test now.
        class Foo(unittest.TestCase):
            def setUp(self):
                self.skipTest("testing")
            def test_nothing(self): pass
        events = []
        result = LoggingResult(events)
        test = Foo("test_nothing")
        test.run(result)
        self.assertEqual(events, ['startTest', 'addSkip', 'stopTest'])
        self.assertEqual(result.skipped, [(test, "testing")])
        self.assertEqual(result.testsRun, 1) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:25,代码来源:test_skipping.py

示例5: test_decorated_skip

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def test_decorated_skip(self):
        def decorator(func):
            def inner(*a):
                return func(*a)
            return inner

        class Foo(unittest.TestCase):
            @decorator
            @unittest.skip('testing')
            def test_1(self):
                pass

        result = unittest.TestResult()
        test = Foo("test_1")
        suite = unittest.TestSuite([test])
        suite.run(result)
        self.assertEqual(result.skipped, [(test, "testing")]) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:19,代码来源:test_skipping.py

示例6: test_float_cast

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def test_float_cast(self):

        self.assertEqual(kilo(1) + 2, 1002.)
        self.assertEqual(2 + kilo(1), 1002.)
        self.assertEqual(kilo(1) - 2, 998.)
        self.assertEqual(2 - kilo(1), -998.)

        self.assertEqual(math.sqrt(kilo(10)), 100)

        array1 = np.array([1., 2., 3.])
        np_test.assert_almost_equal(kilo(1) * array1, array1 * 1000.)
        np_test.assert_almost_equal(array1 * kilo(1), array1 * 1000.)
        np_test.assert_almost_equal(kilo(1) / array1, 1000. / array1)
        np_test.assert_almost_equal(kilo(1) // array1, 1000. // array1)
        np_test.assert_almost_equal(array1 / kilo(1), array1 / 1000.)
        np_test.assert_almost_equal(array1 // kilo(1), array1 // 1000.)

    ##############################################

    # @unittest.skip('') 
开发者ID:FabriceSalvaire,项目名称:PySpice,代码行数:22,代码来源:test_Units.py

示例7: test_canonisation

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def test_canonisation(self):

        self._test_canonise(unit_value(-.0009), '-900.0u')
        self._test_canonise(unit_value(-.001), '-1.0m')
        self._test_canonise(unit_value(.0009999), '999.9u')
        self._test_canonise(unit_value(.001), '1.0m')
        self._test_canonise(unit_value(.010), '10.0m')
        self._test_canonise(unit_value(.100), '100.0m')
        self._test_canonise(unit_value(.999), '999.0m')
        self._test_canonise(kilo(.0001), '100.0m')
        self._test_canonise(kilo(.001), '1.0')
        self._test_canonise(kilo(.100), '100.0')
        self._test_canonise(kilo(.999), '999.0')
        self._test_canonise(kilo(1), '1k') # Fixme: .0
        self._test_canonise(kilo(1000), '1.0Meg')

    ##############################################

    # @unittest.skip('') 
开发者ID:FabriceSalvaire,项目名称:PySpice,代码行数:21,代码来源:test_Units.py

示例8: timeTemplate

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def timeTemplate(self, module, module_name, *args, **kwargs):
        with torch.cuda.device(self.device):
            torch.cuda.empty_cache()
        if isinstance(module, nn.Module):
            module.eval()

        start_time = time.time()

        for i in range(self.iters):
            with torch.no_grad():
                if len(args) > 0:
                    module(*args)
                if len(kwargs) > 0:
                    module(**kwargs)
                torch.cuda.synchronize(self.device)
        end_time = time.time()
        avg_time = (end_time - start_time) / self.iters
        print('{} reference forward once takes {:.4f}ms, i.e. {:.2f}fps'.format(module_name, avg_time*1000, (1 / avg_time)))

        if isinstance(module, nn.Module):
            module.train()

        self.avg_time[module_name] = avg_time

    # @unittest.skip("demonstrating skipping") 
开发者ID:DeepMotionAIResearch,项目名称:DenseMatchingBenchmark,代码行数:27,代码来源:test_model.py

示例9: test_0_TrainingPhase

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def test_0_TrainingPhase(self):
        h, w = self.cfg.data.train.input_shape
        leftImage = torch.rand(1, 3, h, w).to(self.device)
        rightImage = torch.rand(1, 3, h, w).to(self.device)
        leftDisp = torch.rand(1, 1, h, w).to(self.device)
        batch = {'leftImage': leftImage,
                 'rightImage': rightImage,
                 'leftDisp': leftDisp,
                 }

        self.model.train()
        _, loss_dict = self.model(batch)

        print('\n', '*'*40, 'Train Result', '*'*40)
        for k, v in loss_dict.items():
            print(k, v)

        print(self.model.loss_evaluator.loss_evaluators)
        if hasattr(self.cfg.model, 'cmn'):
            print(self.model.cmn.loss_evaluator.loss_evaluators)

    # @unittest.skip("demonstrating skipping") 
开发者ID:DeepMotionAIResearch,项目名称:DenseMatchingBenchmark,代码行数:24,代码来源:test_model.py

示例10: timeTemplate

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def timeTemplate(self, module, module_name, *args, **kwargs):
        with torch.cuda.device(self.device):
            torch.cuda.empty_cache()
        if isinstance(module, nn.Module):
            module.eval()

        start_time = time.time()

        for i in range(self.iters):
            with torch.no_grad():
                if len(args) > 0:
                    module(*args)
                if len(kwargs) > 0:
                    module(**kwargs)
                torch.cuda.synchronize(self.device)
        end_time = time.time()
        avg_time = (end_time - start_time) / self.iters
        print('{} reference forward once takes {:.4f}s, i.e. {:.2f}fps'.format(module_name, avg_time, (1 / avg_time)))

        if isinstance(module, nn.Module):
            module.train()

    # @unittest.skip("Just skipping") 
开发者ID:DeepMotionAIResearch,项目名称:DenseMatchingBenchmark,代码行数:25,代码来源:test_cat_fms.py

示例11: test_skip_doesnt_run_setup

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def test_skip_doesnt_run_setup(self):
        class Foo(unittest.TestCase):
            wasSetUp = False
            wasTornDown = False
            def setUp(self):
                Foo.wasSetUp = True
            def tornDown(self):
                Foo.wasTornDown = True
            @unittest.skip('testing')
            def test_1(self):
                pass

        result = unittest.TestResult()
        test = Foo("test_1")
        suite = unittest.TestSuite([test])
        suite.run(result)
        self.assertEqual(result.skipped, [(test, "testing")])
        self.assertFalse(Foo.wasSetUp)
        self.assertFalse(Foo.wasTornDown) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:test_skipping.py

示例12: test_set_reuse_addr

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def test_set_reuse_addr(self):
        sock = socket.socket()
        try:
            sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        except socket.error:
            unittest.skip("SO_REUSEADDR not supported on this platform")
        else:
            # if SO_REUSEADDR succeeded for sock we expect asyncore
            # to do the same
            s = asyncore.dispatcher(socket.socket())
            self.assertFalse(s.socket.getsockopt(socket.SOL_SOCKET,
                                                 socket.SO_REUSEADDR))
            s.create_socket(socket.AF_INET, socket.SOCK_STREAM)
            s.set_reuse_addr()
            self.assertTrue(s.socket.getsockopt(socket.SOL_SOCKET,
                                                 socket.SO_REUSEADDR))
        finally:
            sock.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_asyncore.py

示例13: test_hexoct

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def test_hexoct(self):
        """returning non-string from hex & oct should throw"""
        
        class foo(object):
            def __hex__(self): return self
            def __oct__(self): return self
            
        class bar:
            def __hex__(self): return self
            def __oct__(self): return self
            
        self.assertRaises(TypeError, hex, foo())
        self.assertRaises(TypeError, oct, foo())
        self.assertRaises(TypeError, hex, bar())
        self.assertRaises(TypeError, oct, bar())

    #TODO: @skip("multiple_execute") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_class.py

示例14: test_override_container_len

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def test_override_container_len(self):
        for x in (dict, list, tuple):
            class C(x):
                def __len__(self): return 2
            
            self.assertEqual(C().__len__(), 2)
            self.assertEqual(len(C()), 2)
            
            self.assertEqual(C(), x())
            
            if x is dict:
                self.assertEqual(C({1:1}), {1:1})
                d = {1:1, 2:2, 3:3}
                self.assertEqual(C(d).__cmp__({0:0, 1:1, 2:2}), 1)
                d[4] = 4
                self.assertEqual(len(list(C(d).iterkeys())), len(list(d.iterkeys())))
            else:
                self.assertEqual(C([1]), x([1]))
                a = range(4)
                self.assertEqual(len(list(iter(C(a)))), len(list(iter(x(a)))))

    #TODO:@skip("multiple_execute") #http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=17551 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:test_class.py

示例15: test_constructed_module

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skip [as 别名]
def test_constructed_module(self):
        """verify that we don't load arbitrary modules from modules, only truly nested modules"""
        ModuleType = type(sys)

        TopModule = ModuleType("TopModule")
        sys.modules["TopModule"] = TopModule

        SubModule = ModuleType("SubModule")
        SubModule.Object = object()
        TopModule.SubModule = SubModule

        try:
            import TopModule.SubModule
            self.assertUnreachable()
        except ImportError:
            pass

        del sys.modules['TopModule']

    #TODO: @skip("multiple_execute") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_imp.py


注:本文中的unittest.skip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。