Before writing a series of nose framework, this introduction under attr tag
In the nose framework, attr is used to identify use cases so that they can be executed by identity at run time, previously described in the Nose test framework, but not clearly explained here.
First, the way of identification
There are two ways of marking:
1, way one (not very good)
def test_learn_1 (): u' test ' Print ' XXX ' Eq_ (7, 7, Msg=u" error ") test_learn_1.slow=1
2, using the attr decorative device
fromNose.plugins.attribImportattr@attr (Mode=2) deftest_lean_2 (): U" "Test Failed" " Try: Print "test_learn_2"Ok_ (4==3,msg="XXX") Printsys._getframe (). F_code.co_nameexceptException:PrintSys._getframe (). F_code.co_name
or direct attr
@attr ('afdfd'def test_lean_3 (): u' Test success ' pass
Second, the operation
Run as follows:
Use-A or--attr to identify
Nosetests-a mode=2
Indicates that only the mode equals 2 in the identity is run
Nosetests-a MODE=2,AFDFD
Indicates that the run contains a use case with mode equal to 2 in the identity and AFDFD in the identity, noting that it contains both
Nosetests-a mode=2-a SAFDFD
Represents a use case that contains an identity mode equal to 2 or a SAFDFD in the identity, note that the relationship is or
Similarly, the-a can be followed by regular expressions to run, but I use very little, basically useless, also introduced
Note that to use this approach, you use the-A or--eval-attr parameter to identify
" Not AFDFD "
" (Mode > 5) and not AFDFD "
Reprint please indicate source: landhu.cnblogs.com
The Python Nose test Framework provides a comprehensive introduction to the five--attr