SlideShare uma empresa Scribd logo
1 de 5
Baixar para ler offline
nose-parameterized
Speaker: Ben Lee
ben@simplelife.com
Example test with parameterized decorator
import unittest
from nose_parameterized import parameterized
class AddTestCase(unittest.TestCase):
@parameterized.expand([
("2 plus 3", 2, 3, 5),
("3 plus 5", 3, 5, 8),
])
def test_add(self, _, a, b, expected):
self.assertEqual(a + b, expected)
Dynamically created tests
$ nosetests example.py --verbosity=2
test_add_0_2_plus_3 (example.AddTestCase) ... ok
test_add_1_3_plus_5 (example.AddTestCase) ... ok
----------------------------------------------------------------------
Ran 2 tests in 0.001s
OK
Some Use Cases
● Write less code to generate many tests with different parameters
● We use it at SimpleLife to test 15 different scenarios of a django FormWizard
view that has 7-8 steps
○ (given inputs [a,b,c,...], we expect to see [x,y,z,..]
● Use it to test APIs
○ input is JSON blob X, expect JSON blob Y as output
https://github.com/wolever/nose-parameterized
We’re hiring full stack Django devs!

Mais conteúdo relacionado

Mais procurados

Application of recursive perturbation approach for multimodal optimization
Application of recursive perturbation approach for multimodal optimizationApplication of recursive perturbation approach for multimodal optimization
Application of recursive perturbation approach for multimodal optimization
Pranamesh Chakraborty
 
Comparative study of algorithms of nonlinear optimization
Comparative study of algorithms of nonlinear optimizationComparative study of algorithms of nonlinear optimization
Comparative study of algorithms of nonlinear optimization
Pranamesh Chakraborty
 
using Queue Server for batch processing
using Queue Server for batch processingusing Queue Server for batch processing
using Queue Server for batch processing
Ching Yi Chan
 
15 2. arguement passing to main
15 2. arguement passing to main15 2. arguement passing to main
15 2. arguement passing to main
웅식 전
 

Mais procurados (20)

Spock Framework - Slidecast
Spock Framework - SlidecastSpock Framework - Slidecast
Spock Framework - Slidecast
 
Elixir @ Paris.rb
Elixir @ Paris.rbElixir @ Paris.rb
Elixir @ Paris.rb
 
Ruby's Arrays and Hashes with examples
Ruby's Arrays and Hashes with examplesRuby's Arrays and Hashes with examples
Ruby's Arrays and Hashes with examples
 
Worst
WorstWorst
Worst
 
Ruby Language: Array, Hash and Iterators
Ruby Language: Array, Hash and IteratorsRuby Language: Array, Hash and Iterators
Ruby Language: Array, Hash and Iterators
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
 
Python profiling
Python profilingPython profiling
Python profiling
 
Python 1 liners
Python 1 linersPython 1 liners
Python 1 liners
 
大量地区化解决方案V5
大量地区化解决方案V5大量地区化解决方案V5
大量地区化解决方案V5
 
Annals of Statistics読み回 第一回
Annals of Statistics読み回 第一回Annals of Statistics読み回 第一回
Annals of Statistics読み回 第一回
 
Interfaz Grafica En Java
Interfaz Grafica En JavaInterfaz Grafica En Java
Interfaz Grafica En Java
 
Data mining in Apriori and FP-tree
Data mining in Apriori and FP-treeData mining in Apriori and FP-tree
Data mining in Apriori and FP-tree
 
Application of recursive perturbation approach for multimodal optimization
Application of recursive perturbation approach for multimodal optimizationApplication of recursive perturbation approach for multimodal optimization
Application of recursive perturbation approach for multimodal optimization
 
Comparative study of algorithms of nonlinear optimization
Comparative study of algorithms of nonlinear optimizationComparative study of algorithms of nonlinear optimization
Comparative study of algorithms of nonlinear optimization
 
03 standard Data Types
03 standard Data Types 03 standard Data Types
03 standard Data Types
 
Postgres can do THAT?
Postgres can do THAT?Postgres can do THAT?
Postgres can do THAT?
 
using Queue Server for batch processing
using Queue Server for batch processingusing Queue Server for batch processing
using Queue Server for batch processing
 
15 2. arguement passing to main
15 2. arguement passing to main15 2. arguement passing to main
15 2. arguement passing to main
 
Математическая модель системы оценки эффективности реализации программ развит...
Математическая модель системы оценки эффективности реализации программ развит...Математическая модель системы оценки эффективности реализации программ развит...
Математическая модель системы оценки эффективности реализации программ развит...
 
Becoming a better developer with EXPLAIN
Becoming a better developer with EXPLAINBecoming a better developer with EXPLAIN
Becoming a better developer with EXPLAIN
 

Destaque (7)

Programaçãoproj
ProgramaçãoprojProgramaçãoproj
Programaçãoproj
 
3 jornadas de reflexión la infancia en juego. reflexiones generales
3 jornadas de reflexión la infancia en juego. reflexiones generales3 jornadas de reflexión la infancia en juego. reflexiones generales
3 jornadas de reflexión la infancia en juego. reflexiones generales
 
Aula 3 para acetato
Aula 3 para acetatoAula 3 para acetato
Aula 3 para acetato
 
aprendizaje colaborativo ventajas.
aprendizaje colaborativo ventajas.aprendizaje colaborativo ventajas.
aprendizaje colaborativo ventajas.
 
Futurismo para Empreendedores @daniel_egger
Futurismo para Empreendedores @daniel_eggerFuturismo para Empreendedores @daniel_egger
Futurismo para Empreendedores @daniel_egger
 
7112373 aforismos-de-gurdjieff
7112373 aforismos-de-gurdjieff7112373 aforismos-de-gurdjieff
7112373 aforismos-de-gurdjieff
 
Presentación born espacio coworking
Presentación born espacio coworkingPresentación born espacio coworking
Presentación born espacio coworking
 

Semelhante a benpresentation_django

pytest로 파이썬 코드 테스트하기
pytest로 파이썬 코드 테스트하기pytest로 파이썬 코드 테스트하기
pytest로 파이썬 코드 테스트하기
Yeongseon Choe
 
PowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdfPowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdf
outcast96
 

Semelhante a benpresentation_django (20)

Testing My Patience
Testing My PatienceTesting My Patience
Testing My Patience
 
Intro to Testing in Zope, Plone
Intro to Testing in Zope, PloneIntro to Testing in Zope, Plone
Intro to Testing in Zope, Plone
 
pytest로 파이썬 코드 테스트하기
pytest로 파이썬 코드 테스트하기pytest로 파이썬 코드 테스트하기
pytest로 파이썬 코드 테스트하기
 
Test Automation Using Googletest
Test Automation Using GoogletestTest Automation Using Googletest
Test Automation Using Googletest
 
using python module: doctest
using python module: doctestusing python module: doctest
using python module: doctest
 
How to fake_properly
How to fake_properlyHow to fake_properly
How to fake_properly
 
Auto testing!
Auto testing!Auto testing!
Auto testing!
 
unittest in 5 minutes
unittest in 5 minutesunittest in 5 minutes
unittest in 5 minutes
 
Python testing using mock and pytest
Python testing using mock and pytestPython testing using mock and pytest
Python testing using mock and pytest
 
Python testing
Python  testingPython  testing
Python testing
 
5-minute intro to property-based testing in Python with hypothesis
5-minute intro to property-based testing in Python with hypothesis5-minute intro to property-based testing in Python with hypothesis
5-minute intro to property-based testing in Python with hypothesis
 
PowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdfPowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdf
 
Testing orm based code
Testing orm based codeTesting orm based code
Testing orm based code
 
Efficient computational modelling for integrated power plant design - Prof Er...
Efficient computational modelling for integrated power plant design - Prof Er...Efficient computational modelling for integrated power plant design - Prof Er...
Efficient computational modelling for integrated power plant design - Prof Er...
 
Mock it right! A beginner’s guide to world of tests and mocks, Maciej Polańczyk
Mock it right! A beginner’s guide to world of tests and mocks, Maciej PolańczykMock it right! A beginner’s guide to world of tests and mocks, Maciej Polańczyk
Mock it right! A beginner’s guide to world of tests and mocks, Maciej Polańczyk
 
Test driven development_for_php
Test driven development_for_phpTest driven development_for_php
Test driven development_for_php
 
Advanced Django
Advanced DjangoAdvanced Django
Advanced Django
 
Parametrized testing, v2
Parametrized testing, v2Parametrized testing, v2
Parametrized testing, v2
 
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 

benpresentation_django

  • 2. Example test with parameterized decorator import unittest from nose_parameterized import parameterized class AddTestCase(unittest.TestCase): @parameterized.expand([ ("2 plus 3", 2, 3, 5), ("3 plus 5", 3, 5, 8), ]) def test_add(self, _, a, b, expected): self.assertEqual(a + b, expected)
  • 3. Dynamically created tests $ nosetests example.py --verbosity=2 test_add_0_2_plus_3 (example.AddTestCase) ... ok test_add_1_3_plus_5 (example.AddTestCase) ... ok ---------------------------------------------------------------------- Ran 2 tests in 0.001s OK
  • 4. Some Use Cases ● Write less code to generate many tests with different parameters ● We use it at SimpleLife to test 15 different scenarios of a django FormWizard view that has 7-8 steps ○ (given inputs [a,b,c,...], we expect to see [x,y,z,..] ● Use it to test APIs ○ input is JSON blob X, expect JSON blob Y as output