Wednesday 15 August 2012

Nose testing

For Unix like systems the nose will install by using following methods

Install nose using setuptools/distribute:
      easy_install nose
Or pip:
      pip install nose
Or, if you don’t have setuptools/distribute installed, use the download link at right to download the source package, and install it in the normal fashion:
     python setup.py install
 
After installation of the nose you can run tests for your projects by using the following commands  on terminal

     cd path/to/project       
     nosetests

The output like this
..........................................................................................................
   Ran 20 tests in 1.220s
   OK
 
For help with nosetests’ many command-line options, try:
 
   nosetests -h 
 
  -h, --help            show this help message and exit
  -V, --version         Output nose version and exit
  -p, --plugins         Output list of available plugins and exit. Combine
                        with higher verbosity for greater detail
  -v, --verbose         Be more verbose. [NOSE_VERBOSE]
  --verbosity=VERBOSITY
                        Set verbosity; --verbosity=2 is the same as -v
  -q, --quiet           Be less verbose
  -c FILES, --config=FILES
                        Load configuration from config file(s). May be
                        specified multiple times; in that case, all config
                        files will be loaded and combined
   etc

Python3

  • nose supports python3. 
  • Building from source on python3 requires distribute.
  • If you don’t have distribute installed, python3 setup.py install will install . 

Testing with nose 

 

Writing tests is easier

   nose collects tests from unittest,TestCase subclasses.
   you can also write simple test functions, as well as test classes

 

Running tests is easier

   nose collects tests automatically, as long as you follow some simple 
   guidelines for organizing your library and test code 
   Running tests is responsive

 

Setting up your test environment is easier

  nose supports fixtures at the package, module, class, and test case  level

 

 Doing what you want to do is easier

  nose comes with a number ofbuiltin plugins to help you with output capture,  
  error introspection, code coverage, doctests, and more. 

 

Developing with nose

 

Get the code

The stable branch of nose is hosted at googlecode. You should clone this branch if you’re developing a plugin or working on bug fixes for nose:
         hg clone http://python-nose.googlecode.com/hg/ nose-stable
 
The unstable branch of nose is hosted at bitbucket. You should fork this branch if you are developing new features for nose. you can clone the branch:
        hg clone http://bitbucket.org/jpellerin/nose/ nose-unstable

 




 

 

No comments:

Post a Comment