Python's handy test library-nose

Source: Internet
Author: User

Python In addition to UnitTest, there is a faster nose,nose can be said to be a simplification of unittest

But he doesn't need unittest. That must have an intrinsic format, he only needs files, class names, method names, etc. containing test can be

UnitTest is required to manually write the Discover function to traverse the use case

    • Name my test modules/files starting with ' Test_ '.

    • Name my test functions starting with ' test_ '.

    • Name my test classes starting with ' test '.

    • Name my test methods starting with ' Test_ '.

    • Make sure all packages with test code has an ' init.py ' file.

Website address: http://pythontesting.net/framework/nose/nose-introduction/

The introduction of the inside is very detailed, summed up a few common points:

Installation:

Easy_install nose

Run:

nosetests [File]

nosetests [Catalogue]

If you do not add a directory, the default execution of all nose-compliant use cases under the current directory

If you add a directory, run the use case in the specified directory that meets the nose criteria

-V to run the specific process output: nosetests-v

-S prints the print output from the test case to the console, which is very handy when debugging

Nose execution rules: As with UnitTest, the setup is prioritized, the last execution Tesrdown, and the location of the function doesn't matter.

The tools used in nose have many functions, such as unittest-like assertequal

How to use

From nose import tools

And then look inside there's so many ways

Assert_almost_equal
Assert_almost_equals
Assert_dict_contains_subset
Assert_dict_equal
Assert_equal
Assert_equals
Assert_false
Assert_greater
Assert_greater_equal
Assert_in
Assert_is
Assert_is_instance
Assert_is_none
Assert_is_not
Assert_is_not_none
Assert_items_equal
Assert_less
Assert_less_equal
Assert_list_equal
Assert_multi_line_equal
Assert_not_almost_equal
Assert_not_almost_equals
Assert_not_equal
Assert_not_equals
Assert_not_in
Assert_not_is_instance
Assert_not_regexp_matches
Assert_raises
Assert_raises_regexp
Assert_regexp_matches
Assert_sequence_equal
Assert_set_equal
Assert_true
Assert_tuple_equal
Eq_
Istest
Make_decorator
Nontrivial
Nontrivial_all
Nottest
Ok_
Raises
Set_trace
Timed
Trivial
Trivial_all
With_setup

Python's handy test library-nose

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.