SlideShare uma empresa Scribd logo
1 de 60
Baixar para ler offline
funcargs &
     other fun
               with
              pytest


        PyCon AU 2012
       Brianna Laugher
pytest – all the good stuff
✔
    all test styles: unittest, doctest, nose
✔
    boilerplate-free style – natural asserts
✔
    support for running tests distributed, boxed
✔
    generate JUnit-style XML for Jenkins CI
✔
    informative error reporting
✔
    extensible plugins, useful builtins
✔
    skip, xfail, custom markers
✔
    parametrize, generate tests
✔
    monkeypatch
✔
    funcargs!
my background
●
    using pytest seriously for ~18 months at work
●
    really enjoying it!
●
    how it feels to use pytest: →
Graphical Forecast Editor
●
    client/server desktop application used by
    forecasters to generate the (text & graphical)
    forecasts
●
    pilot in VIC, funding to roll out nationally, ~5
    year project, 20+ new devs/testers
●
    existing codebase of Python and C++ (used
    operationally in US)
    ●
        home-grown test suite and runner (via GUI)
informative error reporting
informative error reporting
extensible
●
    e.g. add in unittest assert methods
extensible
●
    e.g. add hook for winpdb
skip
xfail
custom markers
parametrize
generate tests
●
    defined once per module
●
    list/generate data to supply to 1+ tests
●
    way more flexible cf. py.test.mark.parametrize
generate generators!
monkeypatch
funcargs!
funcargs – idealised db example
funcargs – trivial django example
funcargs – trivial GAE examples
funcargs – trivial GAE examples
funcargs – why?
●
    dependency injection, aka inversion of control
    ●
        works a treat with TDD
    ●
        very natural with mocking
    ●
        encourages modular design
funcargs – a real DB example
funcargs – a real DB example
funcargs – to express prereq's
●
    for when a decorator is not powerful enough
funcargs – to hide monkeypatch :)
generate + funcarg - anypython
pytest – the future
test evolution -v0
test evolution - v1
test evolution - v2
test evolution – v3
test evolution - v4
pytest – all the good stuff
✔
    all test styles: unittest, doctest, nose
✔
    boilerplate-free style – natural asserts
✔
    support for running tests distributed, boxed
✔
    generate JUnit-style XML for Jenkins CI
✔
    informative error reporting
✔
    extensible plugins, useful builtins
✔
    skip, xfail, custom markers
✔
    parametrize, generate tests
✔
    monkeypatch
✔
    funcargs!
●
    http://codespeak.net/mailman/listinfo/py-dev
●
    testing-in-python mailing list
●
    Stack Overflow
●
    lead developer Holger Krekel is very
    responsive
pytest.org
credits, thanks, contact
Comic panels from comicallyvintage.tumblr.com
Bureau of Meteorology
●
    In particular, Darius Powell introduced pytest to our
    project


Code examples: gist.github.com/3386951


                       brianna@modernthings.org
    brianna.laugher.id.au / b.laugher@bom.gov.au
                                         @pfctdayelise

Mais conteúdo relacionado

Mais procurados

20111018 boost and gtest
20111018 boost and gtest20111018 boost and gtest
20111018 boost and gtest
Will Shen
 

Mais procurados (20)

Python Testing Fundamentals
Python Testing FundamentalsPython Testing Fundamentals
Python Testing Fundamentals
 
TDD with Python and App Engine
TDD with Python and App EngineTDD with Python and App Engine
TDD with Python and App Engine
 
Test Driven Development Methodology and Philosophy
Test Driven Development Methodology and Philosophy Test Driven Development Methodology and Philosophy
Test Driven Development Methodology and Philosophy
 
Advantages of Python Learning | Why Python
Advantages of Python Learning | Why PythonAdvantages of Python Learning | Why Python
Advantages of Python Learning | Why Python
 
Civilized Git Process
Civilized Git ProcessCivilized Git Process
Civilized Git Process
 
Python unit testing
Python unit testingPython unit testing
Python unit testing
 
It is easy contributing to open source - JCON 2020
It is easy contributing to open source - JCON 2020It is easy contributing to open source - JCON 2020
It is easy contributing to open source - JCON 2020
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHP
 
PyQt Application Development On Maemo
PyQt Application Development On MaemoPyQt Application Development On Maemo
PyQt Application Development On Maemo
 
PHPUnit with Magento
PHPUnit with MagentoPHPUnit with Magento
PHPUnit with Magento
 
Neo4j Graph Database, from PHP
Neo4j Graph Database, from PHPNeo4j Graph Database, from PHP
Neo4j Graph Database, from PHP
 
Testing With OutSystems
Testing With OutSystemsTesting With OutSystems
Testing With OutSystems
 
Es fácil contribuir al open source - Bolivia JUG 2020
Es fácil contribuir al open source - Bolivia JUG 2020Es fácil contribuir al open source - Bolivia JUG 2020
Es fácil contribuir al open source - Bolivia JUG 2020
 
7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...
7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...
7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...
 
Python fundamental course curriculum
Python fundamental course curriculumPython fundamental course curriculum
Python fundamental course curriculum
 
20111018 boost and gtest
20111018 boost and gtest20111018 boost and gtest
20111018 boost and gtest
 
Unit testing (eng)
Unit testing (eng)Unit testing (eng)
Unit testing (eng)
 
Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)
 
Understanding how concurrency work in os
Understanding how concurrency work in osUnderstanding how concurrency work in os
Understanding how concurrency work in os
 
Continuous Integration In Php
Continuous Integration In PhpContinuous Integration In Php
Continuous Integration In Php
 

Semelhante a Funcargs & other fun with pytest

Python Django Intro V0.1
Python Django Intro V0.1Python Django Intro V0.1
Python Django Intro V0.1
Udi Bauman
 

Semelhante a Funcargs & other fun with pytest (20)

1803_STAMP_OpenCloudForum2018
1803_STAMP_OpenCloudForum20181803_STAMP_OpenCloudForum2018
1803_STAMP_OpenCloudForum2018
 
Property-based testing an open-source compiler, pflua (FOSDEM 2015)
Property-based testing an open-source compiler, pflua (FOSDEM 2015)Property-based testing an open-source compiler, pflua (FOSDEM 2015)
Property-based testing an open-source compiler, pflua (FOSDEM 2015)
 
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
 
Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as Code
 
Deploying software at Scale
Deploying software at ScaleDeploying software at Scale
Deploying software at Scale
 
UPC Plone Testing Talk
UPC Plone Testing TalkUPC Plone Testing Talk
UPC Plone Testing Talk
 
Testing Django APIs
Testing Django APIsTesting Django APIs
Testing Django APIs
 
Ui Testing with Ghost Inspector
Ui Testing with Ghost InspectorUi Testing with Ghost Inspector
Ui Testing with Ghost Inspector
 
Towards Continuous Deployment with Django
Towards Continuous Deployment with DjangoTowards Continuous Deployment with Django
Towards Continuous Deployment with Django
 
Software development practices in python
Software development practices in pythonSoftware development practices in python
Software development practices in python
 
Lessons learned from designing QA automation event streaming platform(IoT big...
Lessons learned from designing QA automation event streaming platform(IoT big...Lessons learned from designing QA automation event streaming platform(IoT big...
Lessons learned from designing QA automation event streaming platform(IoT big...
 
CD
CDCD
CD
 
Python Django Intro V0.1
Python Django Intro V0.1Python Django Intro V0.1
Python Django Intro V0.1
 
OSDC 2012 | Devops and Open Source by Kris Buyaert
OSDC 2012 | Devops and Open Source by Kris BuyaertOSDC 2012 | Devops and Open Source by Kris Buyaert
OSDC 2012 | Devops and Open Source by Kris Buyaert
 
OSDC 2012 | Devops and Open Source by Kris Buytaert
OSDC 2012 | Devops and Open Source by Kris BuytaertOSDC 2012 | Devops and Open Source by Kris Buytaert
OSDC 2012 | Devops and Open Source by Kris Buytaert
 
Testing your puppet code
Testing your puppet codeTesting your puppet code
Testing your puppet code
 
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
 
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
 
Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022
 
STAMP: Software Testing Amplification in DevOps, Etienne Sauvage, OW2con'17
STAMP: Software Testing Amplification in DevOps, Etienne Sauvage, OW2con'17STAMP: Software Testing Amplification in DevOps, Etienne Sauvage, OW2con'17
STAMP: Software Testing Amplification in DevOps, Etienne Sauvage, OW2con'17
 

Mais de Brianna Laugher

Mais de Brianna Laugher (20)

So You're A Software Developer, Now What? Exploring Career Growth
So You're A Software Developer, Now What? Exploring Career GrowthSo You're A Software Developer, Now What? Exploring Career Growth
So You're A Software Developer, Now What? Exploring Career Growth
 
CFFSW - Crowdfunded free software
CFFSW - Crowdfunded free softwareCFFSW - Crowdfunded free software
CFFSW - Crowdfunded free software
 
Dynamic viz in the IPython Notebook
Dynamic viz in the IPython NotebookDynamic viz in the IPython Notebook
Dynamic viz in the IPython Notebook
 
Zookeepr: Home-grown conference management software
Zookeepr: Home-grown conference management softwareZookeepr: Home-grown conference management software
Zookeepr: Home-grown conference management software
 
BarCamp Geelong - Why gender should be a text field
BarCamp Geelong - Why gender should be a text fieldBarCamp Geelong - Why gender should be a text field
BarCamp Geelong - Why gender should be a text field
 
Distributed wikis
Distributed wikisDistributed wikis
Distributed wikis
 
Neurosexism
NeurosexismNeurosexism
Neurosexism
 
Clash of the encyclopedias - is competition good for sharing?
Clash of the encyclopedias - is competition good for sharing?Clash of the encyclopedias - is competition good for sharing?
Clash of the encyclopedias - is competition good for sharing?
 
Language Sleuthing HOWTO with NLTK
Language Sleuthing HOWTO with NLTKLanguage Sleuthing HOWTO with NLTK
Language Sleuthing HOWTO with NLTK
 
Visualising geo-data
Visualising geo-dataVisualising geo-data
Visualising geo-data
 
Wiki[mp]edia data sources & the MediaWiki API
Wiki[mp]edia data sources & the MediaWiki APIWiki[mp]edia data sources & the MediaWiki API
Wiki[mp]edia data sources & the MediaWiki API
 
GLAM-WIKI - Wikimedia tech infrastructure
GLAM-WIKI - Wikimedia tech infrastructureGLAM-WIKI - Wikimedia tech infrastructure
GLAM-WIKI - Wikimedia tech infrastructure
 
The right level of detail (MediaWiki, APIs)
The right level of detail (MediaWiki, APIs)The right level of detail (MediaWiki, APIs)
The right level of detail (MediaWiki, APIs)
 
Free as in Market: Liberty and Property - Rusty Russell
Free as in Market: Liberty and Property - Rusty RussellFree as in Market: Liberty and Property - Rusty Russell
Free as in Market: Liberty and Property - Rusty Russell
 
Public history in the digital age - Claudine Chionh
Public history in the digital age - Claudine ChionhPublic history in the digital age - Claudine Chionh
Public history in the digital age - Claudine Chionh
 
It's all fun and games until someone wants to sue you: Reporting in the age o...
It's all fun and games until someone wants to sue you: Reporting in the age o...It's all fun and games until someone wants to sue you: Reporting in the age o...
It's all fun and games until someone wants to sue you: Reporting in the age o...
 
Gratis & libre - Liam Wyatt
Gratis & libre - Liam WyattGratis & libre - Liam Wyatt
Gratis & libre - Liam Wyatt
 
OpenAustralia - Everyday democracy for everybody in Australia - Matthew Landauer
OpenAustralia - Everyday democracy for everybody in Australia - Matthew LandauerOpenAustralia - Everyday democracy for everybody in Australia - Matthew Landauer
OpenAustralia - Everyday democracy for everybody in Australia - Matthew Landauer
 
Freedom Fighting: How do we convince the powers that be to relax their grip? ...
Freedom Fighting: How do we convince the powers that be to relax their grip? ...Freedom Fighting: How do we convince the powers that be to relax their grip? ...
Freedom Fighting: How do we convince the powers that be to relax their grip? ...
 
Free and open geodata: From shadows to reality - Simon Greener
Free and open geodata: From shadows to reality - Simon GreenerFree and open geodata: From shadows to reality - Simon Greener
Free and open geodata: From shadows to reality - Simon Greener
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

Funcargs & other fun with pytest