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

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 (20)

PDF
Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...
ODP
20120314 changa-python-workshop
PDF
Making the most of your Test Suite
PDF
ZCA: A component architecture for Python
PPT
Where's the source, Luke? : How to find and debug the code behind Plone
ODP
Pythonpresent
ODP
biopython, doctest and makefiles
PDF
Plone testingdzug tagung2010
PDF
Software development practices in python
PDF
UPC Testing talk 2
PDF
Plone Einführung
PPT
Mufix Network Programming Lecture
PPTX
Pynvme introduction
PDF
Python Foundation – A programmer's introduction to Python concepts & style
PPTX
Sour Pickles
PDF
PyCon 2013 : Scripting to PyPi to GitHub and More
PDF
Pemrograman Python untuk Pemula
PDF
Python Interview Questions And Answers 2019 | Edureka
PDF
05 python.pdf
PDF
Pyhton-1a-Basics.pdf
Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...
20120314 changa-python-workshop
Making the most of your Test Suite
ZCA: A component architecture for Python
Where's the source, Luke? : How to find and debug the code behind Plone
Pythonpresent
biopython, doctest and makefiles
Plone testingdzug tagung2010
Software development practices in python
UPC Testing talk 2
Plone Einführung
Mufix Network Programming Lecture
Pynvme introduction
Python Foundation – A programmer's introduction to Python concepts & style
Sour Pickles
PyCon 2013 : Scripting to PyPi to GitHub and More
Pemrograman Python untuk Pemula
Python Interview Questions And Answers 2019 | Edureka
05 python.pdf
Pyhton-1a-Basics.pdf

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
Einführung Test-driven Development
PDF
Test-Driven Development
PDF
Mock testing mit Python
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...
Einführung Test-driven Development
Test-Driven Development
Mock testing mit Python

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
A Presentation on Artificial Intelligence
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPT
Teaching material agriculture food technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Agricultural_Statistics_at_a_Glance_2022_0.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation theory and applications.pdf
Electronic commerce courselecture one. Pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
“AI and Expert System Decision Support & Business Intelligence Systems”
A Presentation on Artificial Intelligence
Encapsulation_ Review paper, used for researhc scholars
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Teaching material agriculture food technology
Network Security Unit 5.pdf for BCA BBA.
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Advanced methodologies resolving dimensionality complications for autism neur...

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