SlideShare a Scribd company logo
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

What's hot (20)

PDF
Effective testing with pytest
Hector Canto
 
PDF
Python testing using mock and pytest
Suraj Deshmukh
 
ODP
Testes pythonicos com pytest
viniciusban
 
PPT
Google C++ Testing Framework in Visual Studio 2008
Andrea Francia
 
PDF
Python Testing Fundamentals
cbcunc
 
PDF
Py.test
soasme
 
PPT
20111018 boost and gtest
Will Shen
 
ODT
Testing in-python-and-pytest-framework
Arulalan T
 
PPTX
Python Programming Essentials - M39 - Unit Testing
P3 InfoTech Solutions Pvt. Ltd.
 
ODP
Automated testing in Python and beyond
dn
 
PDF
Keep your repo clean
Hector Canto
 
PPT
Introduzione al TDD
Andrea Francia
 
PPTX
Python Programming Essentials - M25 - os and sys modules
P3 InfoTech Solutions Pvt. Ltd.
 
PPTX
Automated Python Test Frameworks for Hardware Verification and Validation
Barbara Jones
 
PPT
Flex Unit 4 Feature Overview
jeff tapper
 
PPT
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Lohika_Odessa_TechTalks
 
PPT
Test Driven Development with PHPUnit
Mindfire Solutions
 
PDF
Golang dot-testing-lite
Richárd Kovács
 
PDF
Test your code like a pro - PHPUnit in practice
Sebastian Marek
 
Effective testing with pytest
Hector Canto
 
Python testing using mock and pytest
Suraj Deshmukh
 
Testes pythonicos com pytest
viniciusban
 
Google C++ Testing Framework in Visual Studio 2008
Andrea Francia
 
Python Testing Fundamentals
cbcunc
 
Py.test
soasme
 
20111018 boost and gtest
Will Shen
 
Testing in-python-and-pytest-framework
Arulalan T
 
Python Programming Essentials - M39 - Unit Testing
P3 InfoTech Solutions Pvt. Ltd.
 
Automated testing in Python and beyond
dn
 
Keep your repo clean
Hector Canto
 
Introduzione al TDD
Andrea Francia
 
Python Programming Essentials - M25 - os and sys modules
P3 InfoTech Solutions Pvt. Ltd.
 
Automated Python Test Frameworks for Hardware Verification and Validation
Barbara Jones
 
Flex Unit 4 Feature Overview
jeff tapper
 
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Lohika_Odessa_TechTalks
 
Test Driven Development with PHPUnit
Mindfire Solutions
 
Golang dot-testing-lite
Richárd Kovács
 
Test your code like a pro - PHPUnit in practice
Sebastian Marek
 

Viewers also liked (20)

PPTX
Unit Testing with Python
MicroPyramid .
 
PDF
Python Ireland Nov 2010 Talk: Unit Testing
Python Ireland
 
PDF
TDD in Python With Pytest
Eddy Reyes
 
PPTX
2014/07/07 Software Testing - Truong Anh Hoang
Vu Hung Nguyen
 
PDF
Web API Test Automation Using Frisby & Node.js
Ho Chi Minh City Software Testing Club
 
PDF
Common Web UI Problems Transforming Manual to Automation
Ho Chi Minh City Software Testing Club
 
PDF
Security testing-What can we do - Trinh Minh Hien
Ho Chi Minh City Software Testing Club
 
PDF
[HCMC STC Jan 2015] Making IT Count – Agile Test Metrics
Ho Chi Minh City Software Testing Club
 
PDF
A Novel Approach of Automation Test for Software Monitoring Solution - Tran S...
Ho Chi Minh City Software Testing Club
 
PDF
[HCMC STC Jan 2015] Practical Experiences In Test Automation
Ho Chi Minh City Software Testing Club
 
PDF
Deliver Fast, Break Nothing Via Effective Building Developer and Tester Colla...
Ho Chi Minh City Software Testing Club
 
PDF
[HCMC STC Jan 2015] FATS: A Framework For Automated Testing Scenarios
Ho Chi Minh City Software Testing Club
 
PDF
Agile Testing - Not Just Tester’s Story _ Dang Thanh Long
Ho Chi Minh City Software Testing Club
 
PDF
Building an effective mobile testing strategy
Ho Chi Minh City Software Testing Club
 
PDF
The New Agile Testing Quadrants: Bringing Skilled Testers and Developers Toge...
Ho Chi Minh City Software Testing Club
 
PDF
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
Ho Chi Minh City Software Testing Club
 
PDF
Test Design with Action-based Testing Methodology - Ngo Hoang Minh
Ho Chi Minh City Software Testing Club
 
PDF
Analytical Risk-based and Specification-based Testing - Bui Duy Tam
Ho Chi Minh City Software Testing Club
 
PDF
[HCMC STC Jan 2015] Risk-Based Software Testing Approaches
Ho Chi Minh City Software Testing Club
 
PDF
Introduction to Back End Automation Testing - Nguyen Vu Hoang, Hoang Phi
Ho Chi Minh City Software Testing Club
 
Unit Testing with Python
MicroPyramid .
 
Python Ireland Nov 2010 Talk: Unit Testing
Python Ireland
 
TDD in Python With Pytest
Eddy Reyes
 
2014/07/07 Software Testing - Truong Anh Hoang
Vu Hung Nguyen
 
Web API Test Automation Using Frisby & Node.js
Ho Chi Minh City Software Testing Club
 
Common Web UI Problems Transforming Manual to Automation
Ho Chi Minh City Software Testing Club
 
Security testing-What can we do - Trinh Minh Hien
Ho Chi Minh City Software Testing Club
 
[HCMC STC Jan 2015] Making IT Count – Agile Test Metrics
Ho Chi Minh City Software Testing Club
 
A Novel Approach of Automation Test for Software Monitoring Solution - Tran S...
Ho Chi Minh City Software Testing Club
 
[HCMC STC Jan 2015] Practical Experiences In Test Automation
Ho Chi Minh City Software Testing Club
 
Deliver Fast, Break Nothing Via Effective Building Developer and Tester Colla...
Ho Chi Minh City Software Testing Club
 
[HCMC STC Jan 2015] FATS: A Framework For Automated Testing Scenarios
Ho Chi Minh City Software Testing Club
 
Agile Testing - Not Just Tester’s Story _ Dang Thanh Long
Ho Chi Minh City Software Testing Club
 
Building an effective mobile testing strategy
Ho Chi Minh City Software Testing Club
 
The New Agile Testing Quadrants: Bringing Skilled Testers and Developers Toge...
Ho Chi Minh City Software Testing Club
 
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
Ho Chi Minh City Software Testing Club
 
Test Design with Action-based Testing Methodology - Ngo Hoang Minh
Ho Chi Minh City Software Testing Club
 
Analytical Risk-based and Specification-based Testing - Bui Duy Tam
Ho Chi Minh City Software Testing Club
 
[HCMC STC Jan 2015] Risk-Based Software Testing Approaches
Ho Chi Minh City Software Testing Club
 
Introduction to Back End Automation Testing - Nguyen Vu Hoang, Hoang Phi
Ho Chi Minh City Software Testing Club
 
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
Cesar Cardenas Desales
 
PDF
Testing Workshop
michaeldunstan
 
PDF
Mock Introduction
Tim (文昌)
 
PDF
Writing tests
Jonathan Fine
 
KEY
20120524 english lt2_pythontoolsfortesting
Kazuhiro Oinuma
 
KEY
Testing My Patience
Adam Lowry
 
PDF
TDD super mondays-june-2014
Alex Kavanagh
 
PDF
Testing Django Applications
Gareth Rushgrove
 
KEY
Django’s nasal passage
Erik Rose
 
PDF
Software development practices in python
Jimmy Lai
 
PDF
UPC Plone Testing Talk
Timo Stollenwerk
 
Unit Testing with Nose
Cesar Cardenas Desales
 
Testing Workshop
michaeldunstan
 
Mock Introduction
Tim (文昌)
 
Writing tests
Jonathan Fine
 
20120524 english lt2_pythontoolsfortesting
Kazuhiro Oinuma
 
Testing My Patience
Adam Lowry
 
TDD super mondays-june-2014
Alex Kavanagh
 
Testing Django Applications
Gareth Rushgrove
 
Django’s nasal passage
Erik Rose
 
Software development practices in python
Jimmy Lai
 
UPC Plone Testing Talk
Timo Stollenwerk
 
Ad

More from Timo Stollenwerk (20)

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

Recently uploaded (20)

PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 

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