zoukankan      html  css  js  c++  java
  • python3 unittest

     
    Code
    import unittest
    class SimplisticTest(unittest.TestCase):
        def test(self):
            a = 'a'
            b = 'a'
            self.assertEqual(a, b)
    Output
    macname@MacdeMacBook-Pro cherry % python3 -m unittest test.py           
    .
    ----------------------------------------------------------------------
    Ran 1 test in 0.000s
     
     
    OK
    macname@MacdeMacBook-Pro cherry %
     
     

     
     
    Code
    import unittest
     
    class OutcomesTest(unittest.TestCase):
        def testPass(self):
            return
        def testFail(self):
            self.assertFalse(True)
        def testError(self):
            raise RuntimeError('Test error!')
     
    Output
    macname@MacdeMacBook-Pro cherry % python3 -m unittest test.py           
    .
    ----------------------------------------------------------------------
    Ran 1 test in 0.000s
     
     
    OK
    macname@MacdeMacBook-Pro cherry % python3 -m unittest test.py
    EF.
    ======================================================================
    ERROR: testError (test.OutcomesTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/macname/Desktop/cherry/test.py", line 8, in testError
        raise RuntimeError('Test error!')
    RuntimeError: Test error!
     
     
    ======================================================================
    FAIL: testFail (test.OutcomesTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/macname/Desktop/cherry/test.py", line 6, in testFail
        self.assertFalse(True)
    AssertionError: True is not false
     
     
    ----------------------------------------------------------------------
    Ran 3 tests in 0.001s
     
     
    FAILED (failures=1, errors=1)
    macname@MacdeMacBook-Pro cherry %
     
     
     
     
     
     
     
     
     
     
     
     
     
     

  • 相关阅读:
    html5-移动端布局模板
    html5-figure和figcaption元素
    html5-hgroup和address元素
    html5-新元素新布局模板-完善中
    数据库操作符
    数据库操作,复制表
    数据库基本sql语句
    反射+工厂模型+Properties
    java :动态代理
    java 反射
  • 原文地址:https://www.cnblogs.com/sea-stream/p/14181691.html
Copyright © 2011-2022 走看看