The Python Nose test Framework provides a comprehensive introduction to the five--attr

Source: Internet
Author: User

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

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.