Python Unit Test Framework-unittest (v) Skip test and expected failure

Source: Internet
Author: User

Profile

    • @unittest. Skip (reason): skip (reason) Adorner: Skip the test directly and explain why you skipped the test.
    • @unittest. SkipIf (reason): SkipIf (Condition,reason) Adorner: When the condition is true, skip the test and explain why the test was skipped
    • @unittest. skipunless (reason): Skipunless (Condition,reason) Adorner: When the condition is false, skip the test and explain the reason for skipping the test
    • @unittest. Expectedfailure (): expectedfailure () test marked as failed.

Instance

1 #Coding=utf-82 ImportUnitTest3 classTest1 (unittest. TestCase):4     defsetUp (self):5         Print("Test1 Start")6     #@unittest. SkipIf (4>3, "Skip Test_d")7     defTest_c (self):8         Print("Test_c")9@unittest. Skipunless (1<0,"Skip Test_b")Ten     defTest_b (self): One         Print("Test_b") A  -     defTearDown (self): -         Print("Test End") the  - #@unittest. Skip ("Skip Test_2") - classTest2 (unittest. TestCase): -     defsetUp (self): +         Print("Test2 Start") -  +     deftest_3 (self): A         Print("Test_3") at @unittest. Expectedfailure -     deftest_2 (self): -        Print("test_2") -  -     defTearDown (self): -         Print("Test2 end!") in if __name__=='__main__': -Unittest.main ()

Python Unit Test Framework-unittest (v) Skip test and expected failure

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.