Python-nose: A unittest-based testing framework
for Python that makes writing and running tests
                     easier

                   Timo Stollenwerk


                    April 27th, 2009




             Timo Stollenwerk   Python-nose: A unittest-based testing framework for Pytho
Introduction




      Usually: Write unit tests with boilerplate code
      Automated test discovery and running process for unittest
      Intended to mimic the behavior of py.test




                     Timo Stollenwerk   Python-nose: A unittest-based testing framework for Pytho
Installation




   $ e a s y _ i n s t a l l nose




                         Timo Stollenwerk   Python-nose: A unittest-based testing framework for Pytho
Egg Installation


  setup.py
  ...
  setup (
       ...
      t e s t _ s u i t e =' n o s e . c o l l e c t o r ' ,
      t e s t _ r e q u i r e s =[ ' nose ' ] ,
      i n s t a l l _ r e q u i r e s =[
              ...
              ' nose ' ,
          ],
       ...
  )



                           Timo Stollenwerk    Python-nose: A unittest-based testing framework for Pytho
Basic Usage




  nosetests [options] [(optional) test les or directories]
  Options
       Test selection (path, package, function, etc.)
       Run only tests with certain attributes
       PDB
       Plugins




                        Timo Stollenwerk   Python-nose: A unittest-based testing framework for Pytho
Basic Usage: Conguration




   /.noserc
  [ nosetests ]
  v e r b o s i t y =3
  with − d o c t e s t =1
  d o c t e s t − e x t e n s i o n =. t x t




                             Timo Stollenwerk   Python-nose: A unittest-based testing framework for Pytho
Writing Unit Tests



  Simplest possible failing test:
  def test ( ) :
      assert False

  And the simplest passing test:
  def test ( ) :
      pass




                        Timo Stollenwerk   Python-nose: A unittest-based testing framework for Pytho
Example Unit Tests


  from l x m l i m p o r t o b j e c t i f y

  c l a s s TestTransform ( ) :

        d e f setUp ( s e l f ) :
              from html2docbook i m p o r t Html2DocBook
              h2d = Html2DocBook ( )
              s e l f . h2d = h2d

        def test_paragraphs ( s e l f ) :
            html = 'plorem /ppipsum /p'
            e x p e c t = ' s e c t i o n paralorem /paraparai
            xml = s e l f . h2d . t r a n s f o r m ( html )
            a s s e r t xml == e x p e c t

                         Timo Stollenwerk   Python-nose: A unittest-based testing framework for Pytho
Automate your Unit tests with Nose




      nosy.py
      Every time you change any .py le, it runs tests




                     Timo Stollenwerk   Python-nose: A unittest-based testing framework for Pytho
Automate your Unit tests with Nose and Eclipse



      Go to the project properties
      Dene a new programbuilder
      Set the location to the nosetest script
      Set the working directory to the project location
      ${workspace_loc:/html2docbook}
      Optional: append any command line options you want
      Go to the build optionstag and tick the launch in
      backgroundänd during auto builds.




                     Timo Stollenwerk   Python-nose: A unittest-based testing framework for Pytho
Conclusion




      Nose makes it easier to write and run useful tests.
      Useful tests make it easier to write less code and better code.




                      Timo Stollenwerk   Python-nose: A unittest-based testing framework for Pytho
Futher Information



      Nose: http://code.google.com/p/python-nose/
      nosy.py: http://jeffwinkler.net/2006/04/27/
      keeping-your-nose-green/
      Automated python testing with nose and eclipse:
      http://www.machine-envy.com/blog/2006/07/29/
      automated-python-testing-with-nose-and-eclipse/
      Pycon 2008 Talk: Testing for the lazy coder
      http://us.pycon.org/common/2008/talkdata/
      PyCon2008/079/nose_pycon08.pdf




                     Timo Stollenwerk   Python-nose: A unittest-based testing framework for Pytho

More Related Content

ODP
Pyunit
PPTX
unittest in 5 minutes
PDF
Python unittest
PDF
Python Unit Test
PDF
Test Driven Development With Python
PPT
Python testing
PDF
Modern Python Testing
PDF
Pytest - testing tips and useful plugins
Pyunit
unittest in 5 minutes
Python unittest
Python Unit Test
Test Driven Development With Python
Python testing
Modern Python Testing
Pytest - testing tips and useful plugins

What's hot (20)

PDF
Effective testing with pytest
PDF
Python testing using mock and pytest
ODP
Testes pythonicos com pytest
PPT
Google C++ Testing Framework in Visual Studio 2008
PDF
Python Testing Fundamentals
PDF
Py.test
PPT
20111018 boost and gtest
ODT
Testing in-python-and-pytest-framework
PPTX
Python Programming Essentials - M39 - Unit Testing
ODP
Automated testing in Python and beyond
 
PDF
Keep your repo clean
PPT
Introduzione al TDD
PPTX
Python Programming Essentials - M25 - os and sys modules
PPTX
Automated Python Test Frameworks for Hardware Verification and Validation
PPT
Flex Unit 4 Feature Overview
PPT
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
PPT
Test Driven Development with PHPUnit
PDF
Golang dot-testing-lite
PDF
Test your code like a pro - PHPUnit in practice
Effective testing with pytest
Python testing using mock and pytest
Testes pythonicos com pytest
Google C++ Testing Framework in Visual Studio 2008
Python Testing Fundamentals
Py.test
20111018 boost and gtest
Testing in-python-and-pytest-framework
Python Programming Essentials - M39 - Unit Testing
Automated testing in Python and beyond
 
Keep your repo clean
Introduzione al TDD
Python Programming Essentials - M25 - os and sys modules
Automated Python Test Frameworks for Hardware Verification and Validation
Flex Unit 4 Feature Overview
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Test Driven Development with PHPUnit
Golang dot-testing-lite
Test your code like a pro - PHPUnit in practice
Ad

Viewers also liked (20)

PPTX
Unit Testing with Python
PDF
Python Ireland Nov 2010 Talk: Unit Testing
PDF
TDD in Python With Pytest
PPTX
2014/07/07 Software Testing - Truong Anh Hoang
PDF
Web API Test Automation Using Frisby & Node.js
PDF
Common Web UI Problems Transforming Manual to Automation
PDF
Security testing-What can we do - Trinh Minh Hien
PDF
[HCMC STC Jan 2015] Making IT Count – Agile Test Metrics
PDF
A Novel Approach of Automation Test for Software Monitoring Solution - Tran S...
PDF
[HCMC STC Jan 2015] Practical Experiences In Test Automation
PDF
Deliver Fast, Break Nothing Via Effective Building Developer and Tester Colla...
PDF
[HCMC STC Jan 2015] FATS: A Framework For Automated Testing Scenarios
PDF
Agile Testing - Not Just Tester’s Story _ Dang Thanh Long
PDF
Building an effective mobile testing strategy
PDF
The New Agile Testing Quadrants: Bringing Skilled Testers and Developers Toge...
PDF
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
PDF
Test Design with Action-based Testing Methodology - Ngo Hoang Minh
PDF
Analytical Risk-based and Specification-based Testing - Bui Duy Tam
PDF
[HCMC STC Jan 2015] Risk-Based Software Testing Approaches
PDF
Introduction to Back End Automation Testing - Nguyen Vu Hoang, Hoang Phi
Unit Testing with Python
Python Ireland Nov 2010 Talk: Unit Testing
TDD in Python With Pytest
2014/07/07 Software Testing - Truong Anh Hoang
Web API Test Automation Using Frisby & Node.js
Common Web UI Problems Transforming Manual to Automation
Security testing-What can we do - Trinh Minh Hien
[HCMC STC Jan 2015] Making IT Count – Agile Test Metrics
A Novel Approach of Automation Test for Software Monitoring Solution - Tran S...
[HCMC STC Jan 2015] Practical Experiences In Test Automation
Deliver Fast, Break Nothing Via Effective Building Developer and Tester Colla...
[HCMC STC Jan 2015] FATS: A Framework For Automated Testing Scenarios
Agile Testing - Not Just Tester’s Story _ Dang Thanh Long
Building an effective mobile testing strategy
The New Agile Testing Quadrants: Bringing Skilled Testers and Developers Toge...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
Test Design with Action-based Testing Methodology - Ngo Hoang Minh
Analytical Risk-based and Specification-based Testing - Bui Duy Tam
[HCMC STC Jan 2015] Risk-Based Software Testing Approaches
Introduction to Back End Automation Testing - Nguyen Vu Hoang, Hoang Phi
Ad

Similar to Python-nose: A unittest-based testing framework for Python that makes writing and running tests easier (11)

PPTX
Unit Testing with Nose
PDF
Testing Workshop
PDF
Mock Introduction
PDF
Writing tests
KEY
20120524 english lt2_pythontoolsfortesting
KEY
Testing My Patience
PDF
TDD super mondays-june-2014
PDF
Testing Django Applications
KEY
Django’s nasal passage
PDF
Software development practices in python
PDF
UPC Plone Testing Talk
Unit Testing with Nose
Testing Workshop
Mock Introduction
Writing tests
20120524 english lt2_pythontoolsfortesting
Testing My Patience
TDD super mondays-june-2014
Testing Django Applications
Django’s nasal passage
Software development practices in python
UPC Plone Testing Talk

More from Timo Stollenwerk (20)

PDF
German Aerospace Center (DLR) Web Relaunch
PDF
Performance Testing (Python Barcamp Cologne 2020)
PDF
Python & JavaScript
PDF
Roadmap to a Headless Plone
PDF
Plone.restapi - a bridge to the modern web
PDF
Divide et impera
PDF
The Butler and The Snake (Europython 2015)
PDF
Hypermedia APIs mit Javascript und Python
PDF
Plone Testing & Continuous Integration Team Report 2014
PDF
The Beauty and the Beast - Modern Javascript Development with AngularJS and P...
PDF
The Butler and the Snake - JCICPH
PDF
The Butler and the Snake - Continuous Integration for Python
PDF
AngularJS & Plone
PDF
Who let the robot out? Qualitativ hochwertige Software durch Continuous Integ...
PDF
PDF
Who let the robot out? - Building high quality software with Continuous Integ...
PDF
The Future Is Written - Building next generation Plone sites with plone.app.c...
PDF
Plone Einführung
PDF
Einführung Test-driven Development
PDF
Test-Driven Development
German Aerospace Center (DLR) Web Relaunch
Performance Testing (Python Barcamp Cologne 2020)
Python & JavaScript
Roadmap to a Headless Plone
Plone.restapi - a bridge to the modern web
Divide et impera
The Butler and The Snake (Europython 2015)
Hypermedia APIs mit Javascript und Python
Plone Testing & Continuous Integration Team Report 2014
The Beauty and the Beast - Modern Javascript Development with AngularJS and P...
The Butler and the Snake - JCICPH
The Butler and the Snake - Continuous Integration for Python
AngularJS & Plone
Who let the robot out? Qualitativ hochwertige Software durch Continuous Integ...
Who let the robot out? - Building high quality software with Continuous Integ...
The Future Is Written - Building next generation Plone sites with plone.app.c...
Plone Einführung
Einführung Test-driven Development
Test-Driven Development

Recently uploaded (20)

PDF
STKI Israel Market Study 2025 version august
PDF
Five Habits of High-Impact Board Members
DOCX
search engine optimization ppt fir known well about this
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
August Patch Tuesday
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
CloudStack 4.21: First Look Webinar slides
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PPT
What is a Computer? Input Devices /output devices
PDF
Unlock new opportunities with location data.pdf
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Architecture types and enterprise applications.pdf
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
Getting started with AI Agents and Multi-Agent Systems
STKI Israel Market Study 2025 version august
Five Habits of High-Impact Board Members
search engine optimization ppt fir known well about this
Assigned Numbers - 2025 - Bluetooth® Document
August Patch Tuesday
sustainability-14-14877-v2.pddhzftheheeeee
CloudStack 4.21: First Look Webinar slides
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
What is a Computer? Input Devices /output devices
Unlock new opportunities with location data.pdf
A contest of sentiment analysis: k-nearest neighbor versus neural network
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Taming the Chaos: How to Turn Unstructured Data into Decisions
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Zenith AI: Advanced Artificial Intelligence
Architecture types and enterprise applications.pdf
Benefits of Physical activity for teenagers.pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Getting started with AI Agents and Multi-Agent Systems

Python-nose: A unittest-based testing framework for Python that makes writing and running tests easier

  • 1. Python-nose: A unittest-based testing framework for Python that makes writing and running tests easier Timo Stollenwerk April 27th, 2009 Timo Stollenwerk Python-nose: A unittest-based testing framework for Pytho
  • 2. Introduction Usually: Write unit tests with boilerplate code Automated test discovery and running process for unittest Intended to mimic the behavior of py.test Timo Stollenwerk Python-nose: A unittest-based testing framework for Pytho
  • 3. Installation $ e a s y _ i n s t a l l nose Timo Stollenwerk Python-nose: A unittest-based testing framework for Pytho
  • 4. Egg Installation setup.py ... setup ( ... t e s t _ s u i t e =' n o s e . c o l l e c t o r ' , t e s t _ r e q u i r e s =[ ' nose ' ] , i n s t a l l _ r e q u i r e s =[ ... ' nose ' , ], ... ) Timo Stollenwerk Python-nose: A unittest-based testing framework for Pytho
  • 5. Basic Usage nosetests [options] [(optional) test les or directories] Options Test selection (path, package, function, etc.) Run only tests with certain attributes PDB Plugins Timo Stollenwerk Python-nose: A unittest-based testing framework for Pytho
  • 6. Basic Usage: Conguration /.noserc [ nosetests ] v e r b o s i t y =3 with − d o c t e s t =1 d o c t e s t − e x t e n s i o n =. t x t Timo Stollenwerk Python-nose: A unittest-based testing framework for Pytho
  • 7. Writing Unit Tests Simplest possible failing test: def test ( ) : assert False And the simplest passing test: def test ( ) : pass Timo Stollenwerk Python-nose: A unittest-based testing framework for Pytho
  • 8. Example Unit Tests from l x m l i m p o r t o b j e c t i f y c l a s s TestTransform ( ) : d e f setUp ( s e l f ) : from html2docbook i m p o r t Html2DocBook h2d = Html2DocBook ( ) s e l f . h2d = h2d def test_paragraphs ( s e l f ) : html = 'plorem /ppipsum /p' e x p e c t = ' s e c t i o n paralorem /paraparai xml = s e l f . h2d . t r a n s f o r m ( html ) a s s e r t xml == e x p e c t Timo Stollenwerk Python-nose: A unittest-based testing framework for Pytho
  • 9. Automate your Unit tests with Nose nosy.py Every time you change any .py le, it runs tests Timo Stollenwerk Python-nose: A unittest-based testing framework for Pytho
  • 10. Automate your Unit tests with Nose and Eclipse Go to the project properties Dene a new programbuilder Set the location to the nosetest script Set the working directory to the project location ${workspace_loc:/html2docbook} Optional: append any command line options you want Go to the build optionstag and tick the launch in backgroundänd during auto builds. Timo Stollenwerk Python-nose: A unittest-based testing framework for Pytho
  • 11. Conclusion Nose makes it easier to write and run useful tests. Useful tests make it easier to write less code and better code. Timo Stollenwerk Python-nose: A unittest-based testing framework for Pytho
  • 12. Futher Information Nose: http://code.google.com/p/python-nose/ nosy.py: http://jeffwinkler.net/2006/04/27/ keeping-your-nose-green/ Automated python testing with nose and eclipse: http://www.machine-envy.com/blog/2006/07/29/ automated-python-testing-with-nose-and-eclipse/ Pycon 2008 Talk: Testing for the lazy coder http://us.pycon.org/common/2008/talkdata/ PyCon2008/079/nose_pycon08.pdf Timo Stollenwerk Python-nose: A unittest-based testing framework for Pytho