Python unittest.skip() Examples
The following are 30 code examples for showing how to use unittest.skip(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
unittest
, or try the search function
.
Example 1
Project: EXOSIMS Author: dsavransky File: test_KnownRVPlanetsTargetList.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
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.")
Example 2
Project: EXOSIMS Author: dsavransky File: test_KnownRVPlanetsTargetList.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
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.")
Example 3
Project: jawfish Author: war-and-code File: test_setups.py License: MIT License | 6 votes |
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)
Example 4
Project: jawfish Author: war-and-code File: test_skipping.py License: MIT License | 6 votes |
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)
Example 5
Project: jawfish Author: war-and-code File: test_skipping.py License: MIT License | 6 votes |
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")])
Example 6
Project: PySpice Author: FabriceSalvaire File: test_Units.py License: GNU General Public License v3.0 | 6 votes |
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('')
Example 7
Project: PySpice Author: FabriceSalvaire File: test_Units.py License: GNU General Public License v3.0 | 6 votes |
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('')
Example 8
Project: DenseMatchingBenchmark Author: DeepMotionAIResearch File: test_model.py License: MIT License | 6 votes |
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")
Example 9
Project: DenseMatchingBenchmark Author: DeepMotionAIResearch File: test_model.py License: MIT License | 6 votes |
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")
Example 10
Project: DenseMatchingBenchmark Author: DeepMotionAIResearch File: test_cat_fms.py License: MIT License | 6 votes |
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")
Example 11
Project: DenseMatchingBenchmark Author: DeepMotionAIResearch File: test_backbones.py License: MIT License | 6 votes |
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")
Example 12
Project: ironpython2 Author: IronLanguages File: test_setups.py License: Apache License 2.0 | 6 votes |
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)
Example 13
Project: ironpython2 Author: IronLanguages File: test_skipping.py License: Apache License 2.0 | 6 votes |
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)
Example 14
Project: ironpython2 Author: IronLanguages File: test_skipping.py License: Apache License 2.0 | 6 votes |
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)
Example 15
Project: ironpython2 Author: IronLanguages File: test_skipping.py License: Apache License 2.0 | 6 votes |
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")])
Example 16
Project: ironpython2 Author: IronLanguages File: test_asyncore.py License: Apache License 2.0 | 6 votes |
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()
Example 17
Project: ironpython2 Author: IronLanguages File: test_class.py License: Apache License 2.0 | 6 votes |
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")
Example 18
Project: ironpython2 Author: IronLanguages File: test_class.py License: Apache License 2.0 | 6 votes |
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
Example 19
Project: ironpython2 Author: IronLanguages File: test_imp.py License: Apache License 2.0 | 6 votes |
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")
Example 20
Project: ironpython2 Author: IronLanguages File: test_importpkg.py License: Apache License 2.0 | 6 votes |
def test_c1cs(self): """verify re-loading an assembly causes the new type to show up""" if not self.has_csc(): return c1cs = get_local_filename('c1.cs') outp = sys.exec_prefix self.compileAndRef('c1', c1cs, '/d:BAR1') import Foo class c1Child(Foo.Bar): pass o = c1Child() self.assertEqual(o.Method(), "In bar1") self.compileAndRef('c1_b', c1cs) import Foo class c2Child(Foo.Bar): pass o = c2Child() self.assertEqual(o.Method(), "In bar2") # ideally we would delete c1.dll, c2.dll here so as to keep them from cluttering up # /Public; however, they need to be present for the peverify pass. #TODO: @skip("multiple_execute")
Example 21
Project: indras_net Author: gcallah File: test_epidemic.py License: GNU General Public License v3.0 | 5 votes |
def is_located(self): self.sal.set_pos(0,0) self.asserIsNotNone(self.sal.get_pos()) # @skip("envirement problem, need to clear region to test isolation")
Example 22
Project: EXOSIMS Author: dsavransky File: test_KnownRVPlanetsTargetList.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def basic_validation(self, tlist): r"""Perform basic validation of TargetList. Factored out into a separate routine to avoid duplication. """ self.assertEqual(tlist._modtype, 'TargetList') self.assertEqual(type(tlist._outspec), type({})) # check for presence of a couple of class attributes self.assertIn('PlanetPopulation', tlist.__dict__) self.assertIn('PlanetPhysicalModel', tlist.__dict__) # @unittest.skip("Skipping init.")
Example 23
Project: EXOSIMS Author: dsavransky File: test_KnownRVPlanetsTargetList.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_init(self): r"""Test of initialization and __init__. """ tlist = self.fixture self.basic_validation(tlist) # @unittest.skip("Skipping init.")
Example 24
Project: EXOSIMS Author: dsavransky File: test_KnownRVPlanetsTargetList.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_populate_target_list(self): r"""Test of populate_target_list. Method: None. populate_target_list is called as part of __init__ and is tested by the __init__ test. """ pass #@unittest.skip("Skip filter_target_list")
Example 25
Project: EXOSIMS Author: dsavransky File: test_KnownRVPlanetsUniverse.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_init(self): r"""Test of initialization and __init__. """ universe = self.fixture self.basic_validation(universe) # @unittest.skip("Skipping init.")
Example 26
Project: jawfish Author: war-and-code File: test_result.py License: MIT License | 5 votes |
def testOldTestResultClass(self): @unittest.skip('no reason') class Test(unittest.TestCase): def testFoo(self): pass self.assertOldResultWarning(Test('testFoo'), 0)
Example 27
Project: jawfish Author: war-and-code File: test_skipping.py License: MIT License | 5 votes |
def test_skip_class(self): @unittest.skip("testing") class Foo(unittest.TestCase): def test_1(self): record.append(1) record = [] result = unittest.TestResult() test = Foo("test_1") suite = unittest.TestSuite([test]) suite.run(result) self.assertEqual(result.skipped, [(test, "testing")]) self.assertEqual(record, [])
Example 28
Project: jawfish Author: war-and-code File: test_skipping.py License: MIT License | 5 votes |
def test_skip_non_unittest_class(self): @unittest.skip("testing") class Mixin: def test_1(self): record.append(1) class Foo(Mixin, unittest.TestCase): pass record = [] result = unittest.TestResult() test = Foo("test_1") suite = unittest.TestSuite([test]) suite.run(result) self.assertEqual(result.skipped, [(test, "testing")]) self.assertEqual(record, [])
Example 29
Project: jawfish Author: war-and-code File: support.py License: MIT License | 5 votes |
def requires_resource(resource): if resource == 'gui' and not _is_gui_available(): return unittest.skip("resource 'gui' is not available") if is_resource_enabled(resource): return _id else: return unittest.skip("resource {0!r} is not enabled".format(resource))
Example 30
Project: jawfish Author: war-and-code File: support.py License: MIT License | 5 votes |
def impl_detail(msg=None, **guards): if check_impl_detail(**guards): return _id if msg is None: guardnames, default = _parse_guards(guards) if default: msg = "implementation detail not available on {0}" else: msg = "implementation detail specific to {0}" guardnames = sorted(guardnames.keys()) msg = msg.format(' or '.join(guardnames)) return unittest.skip(msg)