Python???????????????????????????????????
?????????? ???????[ 2017/6/28 10:57:56 ] ????????Python ??????? ????
????Python???????unittest??????????????????????????????????????????Python 2.7.13??
???????Python????У?
????https://docs.python.org/dev/library/unittest.html
????The following decorators implement test skipping and expected failures:
????#????????????????????????????
????@unittest.skip(???)
????Unconditionally skip the decorated test. reason should describe why the test is being skipped.
????#????????????β???? ??????????????????????
????@unittest.skipIf(?????????)
????Skip the decorated test if condition is true.
????#?????????棬??????β????
????@unittest.skipUnless(?????????)
????Skip the decorated test unless condition is true.
????# ??????ε???????????????????
????@unittest.expectedFailure
????Mark the test as an expected failure. If the test fails when run?? the test is not counted as a failure.
????#????????????????? ?????????????????????????????????
????????????ù?跭????????в???
?????????д?????????£?test.py ??????Eclipse
??#coding:UTF-8
????import unittest
????from test.test_pprint import uni
????class Test_ce(unittest.TestCase):
???? a=16
???? b=10
????
???? @unittest.skip('??????????')
???? def test_ce1(self):
???? self.assertEqual((self.a-self.b)?? 16)
???? #?ж???????
????
???? @unittest.skipIf(True==1?? '?????????????')
???? def test_ce_2(self):
???? self.assertFalse(self.a==self.b)
???? #?ж?????False
????
???? @unittest.skipUnless(1==1?? '?????????????')
???? def test_ce_3(self):
???? self.assertTrue(self.a>16)
???? #?ж?????True
???? @unittest.expectedFailure
???? def test_ce_4(self):
???? self.assertFalse(self.a==16)
????
???? @unittest.expectedFailure
???? def test_ce_5(self):
???? self.assertFalse(self.a==15)
????
????if __name__ == '__main__':
???? unittest.main()
???????????????
???? 1 ssFxu
???? 2 ======================================================================
???? 3 FAIL: test_ce_3 (__main__.Test_ce)
???? 4 ----------------------------------------------------------------------
???? 5 Traceback (most recent call last):
???? 6 File "D:EscpliseworkspacePytestsrc est001CE.py"?? line 20?? in test_ce_3
???? 7 self.assertTrue(self.a>16)
???? 8 AssertionError: False is not true
???? 9
????10 ----------------------------------------------------------------------
????11 Ran 5 tests in 0.000s
????12
????13 FAILED (failures=1?? skipped=2?? expected failures=1?? unexpected successes=1)
??????????????1?д?????з?????
????s:?????skipped????????
????s:??????棬???????skipped????????
????F????????棬????????????????ж???????????failures??????
????x:????????????????????????????????????У???????expected failures??????????
????u:???????????pass????????????????????????????unexpected successes??????????????
????????13?д??? ??? FAILED (failures=1?? skipped=2?? expected failures=1?? unexpected successes=1)
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11