SlideShare a Scribd company logo
UNIT TESTING WITH
NOSE
César Cárdenas Desales
Installing nose
• Install pip
• Install virtualenv
• Install pip on your virtual environment
• http://bit.ly/1kCeZv8
$ wget https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py
$ pip install virtualenv
$ virtualenv testingenv
$ source testingenv/bin/activate
$ python get-pip.py
$ pip install nose
Step 1: Freedom, no unittest boilerplate
$ nosetests
$ nosetests basic_tests.py
$ nosetests basic_tests
Step 2: Test functions
$ nosetests
$ nosetests basic_tests
$ nosetests basic_tests:test_sum
$ nosetests basic_tests:test_failing_sum
Step 3: Test classes
$ nosetests basic_tests:TestSuite
$ nosetests basic_tests:TestSuite.test_mult
$ nosetests basic_tests:TestSuite.ignored
Step 4: Specify tests
$ nosetests --collect-only -v
$ nosetests --collect-only -v -s
$ nosetests -v -s
$ nosetests -v --nocapture
Step 5: Config files
$ nosetests -v -c config.ini
Step 6: Fixtures
=> @with_setup(setup_function, teardown_function)
$ nosetests –v
Step 7: Test generators & parallel testing
1 2 3 4 5
OK OK OK FAIL OK
$ nosetests -v
$ nosetests --processes=6
Step 8: Exceptions
$ nosetests –v
Step 9: Timeouts
$ nosetests -v basic_tests.py
$ nosetests -v --processes=6 --process-timeout=1 basic_tests2
Plugins! => --processes --no-capture –collect-only
Py.test anyone?
$ pip install pytest
$ py.test step1/basic_tests.py
$ py.test step2/basic_tests.py
$ py.test -v step4/basic_tests.py
...
Is TDD dead?
• No need to be purist and orthodox
• “I get paid for code that works, not for tests, so my philosophy is to
test as little as possible to reach a given level of confidence”
• – Kent Beck
• Test are code to maintain
• Test core algorithms, data structures, logic with Biz. Value
• Tests can become assertions
• Test give you confidence to do changes
Exercise
• Test whether the following code correctly calculates in
which quarter falls the provided datetime.date object
¿?
• ¡ !

More Related Content

Viewers also liked

Mallas curriculares
Mallas curricularesMallas curriculares
Mallas curriculares
CrYauri
 
September-2016-Tech-Front
September-2016-Tech-FrontSeptember-2016-Tech-Front
September-2016-Tech-Front
Surojit Ganguli
 
Tema 3 procesos!
Tema 3 procesos!Tema 3 procesos!
Tema 3 procesos!
patry46
 
Tema 1
Tema 1Tema 1
Tema 1
patry46
 
CV Marija Vasiljevic
CV Marija VasiljevicCV Marija Vasiljevic
CV Marija Vasiljevic
Marija Vasiljevic
 
La sociedad-de-la-informacion-1223721720933638-9
La sociedad-de-la-informacion-1223721720933638-9La sociedad-de-la-informacion-1223721720933638-9
La sociedad-de-la-informacion-1223721720933638-9
patry46
 
The making of Arla tactical decision process (S&OP)
The making of Arla tactical decision process (S&OP)The making of Arla tactical decision process (S&OP)
The making of Arla tactical decision process (S&OP)
Jakob Lignell
 
Reglamento terceras matriculas
Reglamento terceras matriculasReglamento terceras matriculas
Reglamento terceras matriculas
CrYauri
 
89001164 mantto sistemas hidraulicos
89001164 mantto sistemas hidraulicos89001164 mantto sistemas hidraulicos
89001164 mantto sistemas hidraulicos
Moises Salcedo Aguilar
 
SOAL IPS
SOAL IPSSOAL IPS
SOAL IPS
ridhojulianto
 

Viewers also liked (10)

Mallas curriculares
Mallas curricularesMallas curriculares
Mallas curriculares
 
September-2016-Tech-Front
September-2016-Tech-FrontSeptember-2016-Tech-Front
September-2016-Tech-Front
 
Tema 3 procesos!
Tema 3 procesos!Tema 3 procesos!
Tema 3 procesos!
 
Tema 1
Tema 1Tema 1
Tema 1
 
CV Marija Vasiljevic
CV Marija VasiljevicCV Marija Vasiljevic
CV Marija Vasiljevic
 
La sociedad-de-la-informacion-1223721720933638-9
La sociedad-de-la-informacion-1223721720933638-9La sociedad-de-la-informacion-1223721720933638-9
La sociedad-de-la-informacion-1223721720933638-9
 
The making of Arla tactical decision process (S&OP)
The making of Arla tactical decision process (S&OP)The making of Arla tactical decision process (S&OP)
The making of Arla tactical decision process (S&OP)
 
Reglamento terceras matriculas
Reglamento terceras matriculasReglamento terceras matriculas
Reglamento terceras matriculas
 
89001164 mantto sistemas hidraulicos
89001164 mantto sistemas hidraulicos89001164 mantto sistemas hidraulicos
89001164 mantto sistemas hidraulicos
 
SOAL IPS
SOAL IPSSOAL IPS
SOAL IPS
 

Similar to Unit Testing with Nose

Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
Larry Cai
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
Markus Zapke-Gründemann
 
Software development practices in python
Software development practices in pythonSoftware development practices in python
Software development practices in python
Jimmy Lai
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
Markus Zapke-Gründemann
 
Virtualenv
VirtualenvVirtualenv
Virtualenv
Jon Nials
 
Virtualenv
VirtualenvVirtualenv
Virtualenv
WEBdeBS
 
Continuous Integration Testing in Django
Continuous Integration Testing in DjangoContinuous Integration Testing in Django
Continuous Integration Testing in Django
Kevin Harvey
 
Using Buildout to Develop and Deploy Python Projects
Using Buildout to Develop and Deploy Python ProjectsUsing Buildout to Develop and Deploy Python Projects
Using Buildout to Develop and Deploy Python Projects
Clayton Parker
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023
Mark Niebergall
 
Continuous Testing and New Tools for Automation - Presentation from StarWest ...
Continuous Testing and New Tools for Automation - Presentation from StarWest ...Continuous Testing and New Tools for Automation - Presentation from StarWest ...
Continuous Testing and New Tools for Automation - Presentation from StarWest ...
Sauce Labs
 
Python+gradle
Python+gradlePython+gradle
Python+gradle
Stephen Holsapple
 
Unit Testing Lots of Perl
Unit Testing Lots of PerlUnit Testing Lots of Perl
Unit Testing Lots of Perl
Workhorse Computing
 
Django’s nasal passage
Django’s nasal passageDjango’s nasal passage
Django’s nasal passage
Erik Rose
 
Transforming the Ceph Integration Tests with OpenStack
Transforming the Ceph Integration Tests with OpenStack Transforming the Ceph Integration Tests with OpenStack
Transforming the Ceph Integration Tests with OpenStack
Ceph Community
 
Puppet getting started by Dirk Götz
Puppet getting started by Dirk GötzPuppet getting started by Dirk Götz
Puppet getting started by Dirk Götz
NETWAYS
 
A.I. Exercise.
A.I. Exercise.A.I. Exercise.
A.I. Exercise.
Mario Cho
 
Development with Ansible & VMs
Development with Ansible & VMsDevelopment with Ansible & VMs
Development with Ansible & VMs
Jeff Schenck
 
Python environments
Python environmentsPython environments
Python environments
Glen Zangirolami
 
Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?
Martin Alfke
 
From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012
Carlos Sanchez
 

Similar to Unit Testing with Nose (20)

Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
 
Software development practices in python
Software development practices in pythonSoftware development practices in python
Software development practices in python
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
 
Virtualenv
VirtualenvVirtualenv
Virtualenv
 
Virtualenv
VirtualenvVirtualenv
Virtualenv
 
Continuous Integration Testing in Django
Continuous Integration Testing in DjangoContinuous Integration Testing in Django
Continuous Integration Testing in Django
 
Using Buildout to Develop and Deploy Python Projects
Using Buildout to Develop and Deploy Python ProjectsUsing Buildout to Develop and Deploy Python Projects
Using Buildout to Develop and Deploy Python Projects
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023
 
Continuous Testing and New Tools for Automation - Presentation from StarWest ...
Continuous Testing and New Tools for Automation - Presentation from StarWest ...Continuous Testing and New Tools for Automation - Presentation from StarWest ...
Continuous Testing and New Tools for Automation - Presentation from StarWest ...
 
Python+gradle
Python+gradlePython+gradle
Python+gradle
 
Unit Testing Lots of Perl
Unit Testing Lots of PerlUnit Testing Lots of Perl
Unit Testing Lots of Perl
 
Django’s nasal passage
Django’s nasal passageDjango’s nasal passage
Django’s nasal passage
 
Transforming the Ceph Integration Tests with OpenStack
Transforming the Ceph Integration Tests with OpenStack Transforming the Ceph Integration Tests with OpenStack
Transforming the Ceph Integration Tests with OpenStack
 
Puppet getting started by Dirk Götz
Puppet getting started by Dirk GötzPuppet getting started by Dirk Götz
Puppet getting started by Dirk Götz
 
A.I. Exercise.
A.I. Exercise.A.I. Exercise.
A.I. Exercise.
 
Development with Ansible & VMs
Development with Ansible & VMsDevelopment with Ansible & VMs
Development with Ansible & VMs
 
Python environments
Python environmentsPython environments
Python environments
 
Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?
 
From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012
 

More from Cesar Cardenas Desales

PyConIT 2018 Writing and deploying serverless python applications
PyConIT 2018 Writing and deploying serverless python applicationsPyConIT 2018 Writing and deploying serverless python applications
PyConIT 2018 Writing and deploying serverless python applications
Cesar Cardenas Desales
 
Migrate to Python 3 using the six library
Migrate to Python 3 using the six libraryMigrate to Python 3 using the six library
Migrate to Python 3 using the six library
Cesar Cardenas Desales
 
PyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsPyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applications
Cesar Cardenas Desales
 
Writing and deploying serverless python applications
Writing and deploying serverless python applicationsWriting and deploying serverless python applications
Writing and deploying serverless python applications
Cesar Cardenas Desales
 
Scalable Web applications with Elastic Beanstalk as your PAAS: a primer
Scalable Web applications with Elastic Beanstalk as your PAAS: a primerScalable Web applications with Elastic Beanstalk as your PAAS: a primer
Scalable Web applications with Elastic Beanstalk as your PAAS: a primer
Cesar Cardenas Desales
 
Software maintenance PyConPL 2016
Software maintenance PyConPL 2016Software maintenance PyConPL 2016
Software maintenance PyConPL 2016
Cesar Cardenas Desales
 
Distributed Task Processing with Celery - PyZH
Distributed Task Processing with Celery - PyZHDistributed Task Processing with Celery - PyZH
Distributed Task Processing with Celery - PyZH
Cesar Cardenas Desales
 
Software maintenance PyConUK 2016
Software maintenance PyConUK 2016Software maintenance PyConUK 2016
Software maintenance PyConUK 2016
Cesar Cardenas Desales
 
Code Reviews in Python - PyZh
Code Reviews in Python - PyZhCode Reviews in Python - PyZh
Code Reviews in Python - PyZh
Cesar Cardenas Desales
 

More from Cesar Cardenas Desales (9)

PyConIT 2018 Writing and deploying serverless python applications
PyConIT 2018 Writing and deploying serverless python applicationsPyConIT 2018 Writing and deploying serverless python applications
PyConIT 2018 Writing and deploying serverless python applications
 
Migrate to Python 3 using the six library
Migrate to Python 3 using the six libraryMigrate to Python 3 using the six library
Migrate to Python 3 using the six library
 
PyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsPyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applications
 
Writing and deploying serverless python applications
Writing and deploying serverless python applicationsWriting and deploying serverless python applications
Writing and deploying serverless python applications
 
Scalable Web applications with Elastic Beanstalk as your PAAS: a primer
Scalable Web applications with Elastic Beanstalk as your PAAS: a primerScalable Web applications with Elastic Beanstalk as your PAAS: a primer
Scalable Web applications with Elastic Beanstalk as your PAAS: a primer
 
Software maintenance PyConPL 2016
Software maintenance PyConPL 2016Software maintenance PyConPL 2016
Software maintenance PyConPL 2016
 
Distributed Task Processing with Celery - PyZH
Distributed Task Processing with Celery - PyZHDistributed Task Processing with Celery - PyZH
Distributed Task Processing with Celery - PyZH
 
Software maintenance PyConUK 2016
Software maintenance PyConUK 2016Software maintenance PyConUK 2016
Software maintenance PyConUK 2016
 
Code Reviews in Python - PyZh
Code Reviews in Python - PyZhCode Reviews in Python - PyZh
Code Reviews in Python - PyZh
 

Recently uploaded

Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 

Recently uploaded (20)

Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 

Unit Testing with Nose

  • 1. UNIT TESTING WITH NOSE César Cárdenas Desales
  • 2. Installing nose • Install pip • Install virtualenv • Install pip on your virtual environment • http://bit.ly/1kCeZv8 $ wget https://bootstrap.pypa.io/get-pip.py $ python get-pip.py $ pip install virtualenv $ virtualenv testingenv $ source testingenv/bin/activate $ python get-pip.py $ pip install nose
  • 3. Step 1: Freedom, no unittest boilerplate $ nosetests $ nosetests basic_tests.py $ nosetests basic_tests
  • 4. Step 2: Test functions $ nosetests $ nosetests basic_tests $ nosetests basic_tests:test_sum $ nosetests basic_tests:test_failing_sum
  • 5. Step 3: Test classes $ nosetests basic_tests:TestSuite $ nosetests basic_tests:TestSuite.test_mult $ nosetests basic_tests:TestSuite.ignored
  • 6. Step 4: Specify tests $ nosetests --collect-only -v $ nosetests --collect-only -v -s $ nosetests -v -s $ nosetests -v --nocapture
  • 7. Step 5: Config files $ nosetests -v -c config.ini
  • 8. Step 6: Fixtures => @with_setup(setup_function, teardown_function) $ nosetests –v
  • 9. Step 7: Test generators & parallel testing 1 2 3 4 5 OK OK OK FAIL OK $ nosetests -v $ nosetests --processes=6
  • 10. Step 8: Exceptions $ nosetests –v
  • 11. Step 9: Timeouts $ nosetests -v basic_tests.py $ nosetests -v --processes=6 --process-timeout=1 basic_tests2 Plugins! => --processes --no-capture –collect-only
  • 12. Py.test anyone? $ pip install pytest $ py.test step1/basic_tests.py $ py.test step2/basic_tests.py $ py.test -v step4/basic_tests.py ...
  • 13. Is TDD dead? • No need to be purist and orthodox • “I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence” • – Kent Beck • Test are code to maintain • Test core algorithms, data structures, logic with Biz. Value • Tests can become assertions • Test give you confidence to do changes
  • 14. Exercise • Test whether the following code correctly calculates in which quarter falls the provided datetime.date object