Python Nose test Framework provides a comprehensive overview of 10---use case skipping

Source: Internet
Author: User

Again to write nose, this time the main introduction nose in the use case to skip the application, before also introduced, see Python Nose testing Framework comprehensive introduction four, but the introduction of the not detailed. The following detailed analysis

Nose's own skiptest

First look at the skiptest typical application of nose

Application One:

"@auth: Hu ' "  from Import skiptest@attr (Mode=1def  test_learn_1 ():    raise skiptest

But this skiptest does not show the Skip keyword in the actual log

Application Two:

If you want to determine the relevant word delusions before executing the use case and then skip the use case as follows

" "@author: Huzq" "ImportNoseImportnose.plugins.multiprocess fromTestToolsImportTestCase fromNoseImportskiptest fromNose.plugins.skipImportSkipImportUnitTestclassTestClass ():defsetUp (self):Print "mytestclass Setup"        if "XXX" inch "QQQQ":            RaiseSkiptest ("ADFDFD")               defTestfunc1 (self):Print "This is Testfunc01"        

Each use case will be judged before it is skipped.

Application Three:

Can feel too cumbersome to write in the code, Skiptest may also be used as adorners, as follows

" "@author: Huzq" "ImportNoseImportnose.plugins.multiprocess fromTestToolsImportTestCase fromNoseImportskiptest fromNose.plugins.skipImportSkipImportUnitTestclassTestClass (): @classmethoddefSetupClass (self):Print "xxxxxx"        defsetUp (self):Print "mytestclass Setup"            defTearDown (self):Print "Mytestclass teardown"@SkipTestdefTestfunc1 (self):Print "This is Testfunc01"        

To pay attention to, if using the adorner form, skiptest can not take the specific reasons, if you want to get specific reasons, can only be written in UnitTest method, as follows

@unittest. Skip ("I don ' t want to run this case. ")

Skiptest can be placed in SetupClass, SetUp, test

Python Nose test Framework provides a comprehensive overview of 10---use case skipping

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.