测试开发

python_unittest套件及装饰器

2017-01-17  本文已影响90人  古佛青灯度流年

固定套件:

装饰器

class MyTestCase(unittest.TestCase):

  @unittest.skip("demonstrating skipping")
  def test_nothing(self):
    self.fail("shouldn't happen")

  @unittest.skipIf(mylib.__version__ < (1, 3),
           "not supported in this library version")
  def test_format(self):
    # Tests that work for only a certain version of the library.
    pass

  @unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
  def test_windows_support(self):
    # windows specific testing code
    pass

@unittest.skip("showing class skipping")
class MySkippedTestCase(unittest.TestCase):
  def test_not_run(self):
    pass

@阴天-2017-01-17 17:50:40

上一篇下一篇

猜你喜欢

热点阅读