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