SlideShare a Scribd company logo
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!
Funcargs & other fun with pytest
my background
●
    using pytest seriously for ~18 months at work
●
    really enjoying it!
●
    how it feels to use pytest: →
Funcargs & other fun with pytest
Funcargs & other fun with pytest
Funcargs & other fun with 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)
Funcargs & other fun with pytest
informative error reporting
informative error reporting
extensible
●
    e.g. add in unittest assert methods
extensible
●
    e.g. add hook for winpdb
Funcargs & other fun with pytest
skip
xfail
custom markers
Funcargs & other fun with pytest
parametrize
Funcargs & other fun with pytest
generate tests
●
    defined once per module
●
    list/generate data to supply to 1+ tests
●
    way more flexible cf. py.test.mark.parametrize
generate generators!
Funcargs & other fun with pytest
monkeypatch
Funcargs & other fun with pytest
Funcargs & other fun with pytest
Funcargs & other fun with pytest
Funcargs & other fun with pytest
funcargs!
funcargs – idealised db example
funcargs – trivial django example
funcargs – trivial GAE examples
funcargs – trivial GAE examples
Funcargs & other fun with pytest
funcargs – why?
●
    dependency injection, aka inversion of control
    ●
        works a treat with TDD
    ●
        very natural with mocking
    ●
        encourages modular design
Funcargs & other fun with pytest
funcargs – a real DB example
funcargs – a real DB example
funcargs – to express prereq's
●
    for when a decorator is not powerful enough
Funcargs & other fun with pytest
funcargs – to hide monkeypatch :)
Funcargs & other fun with pytest
generate + funcarg - anypython
Funcargs & other fun with pytest
Funcargs & other fun with pytest
pytest – the future
Funcargs & other fun with pytest
test evolution -v0
Funcargs & other fun with pytest
test evolution - v1
test evolution - v2
test evolution – v3
test evolution - v4
Funcargs & other fun with pytest
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!
Funcargs & other fun with pytest
Funcargs & other fun with pytest
●
    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

More Related Content

PDF
PyBCN - Pytest: recomendaciones, paquetes básicos para testing en Python y Dj...
PDF
TDD in Python With Pytest
PPTX
TDD in Go with Ginkgo and Gomega
PPTX
Complete python toolbox for modern developers
PPTX
Creating a reasonable project boilerplate
PDF
Tdd presentation
ODP
Automated testing in Python and beyond
 
PDF
TDD for joomla extensions
PyBCN - Pytest: recomendaciones, paquetes básicos para testing en Python y Dj...
TDD in Python With Pytest
TDD in Go with Ginkgo and Gomega
Complete python toolbox for modern developers
Creating a reasonable project boilerplate
Tdd presentation
Automated testing in Python and beyond
 
TDD for joomla extensions

What's hot (20)

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

Similar to Funcargs & other fun with pytest (20)

PPTX
¡El mejor lenguaje para automatizar pruebas!
PDF
Effective testing with pytest
PDF
Py.test
PDF
Write unit test from scratch
PDF
DIY in 5 Minutes: Testing Django App with Pytest
PDF
Token Testing Slides
PDF
Modern Python Testing
PDF
Testing Django Applications
KEY
Django’s nasal passage
PPTX
Testing Django APIs
PDF
Python testing like a pro by Keith Yang
PPTX
Testing Testing everywhere
PPTX
One to rule them all
PDF
Making the most of your Test Suite
PPT
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
PDF
Python testing using mock and pytest
PDF
Plone Conference 2007: Acceptance Testing In Plone Using Funittest - Maik Röder
PDF
Isolated development in python
PDF
PresentationqwertyuiopasdfghUnittest.pdf
PDF
Django Testing
¡El mejor lenguaje para automatizar pruebas!
Effective testing with pytest
Py.test
Write unit test from scratch
DIY in 5 Minutes: Testing Django App with Pytest
Token Testing Slides
Modern Python Testing
Testing Django Applications
Django’s nasal passage
Testing Django APIs
Python testing like a pro by Keith Yang
Testing Testing everywhere
One to rule them all
Making the most of your Test Suite
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Python testing using mock and pytest
Plone Conference 2007: Acceptance Testing In Plone Using Funittest - Maik Röder
Isolated development in python
PresentationqwertyuiopasdfghUnittest.pdf
Django Testing
Ad

More from Brianna Laugher (20)

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

Recently uploaded (20)

PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Empathic Computing: Creating Shared Understanding
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Network Security Unit 5.pdf for BCA BBA.
PPT
Teaching material agriculture food technology
PPTX
Spectroscopy.pptx food analysis technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Electronic commerce courselecture one. Pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Big Data Technologies - Introduction.pptx
PDF
Approach and Philosophy of On baking technology
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
Spectral efficient network and resource selection model in 5G networks
Empathic Computing: Creating Shared Understanding
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Dropbox Q2 2025 Financial Results & Investor Presentation
Per capita expenditure prediction using model stacking based on satellite ima...
Network Security Unit 5.pdf for BCA BBA.
Teaching material agriculture food technology
Spectroscopy.pptx food analysis technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
Electronic commerce courselecture one. Pdf
The AUB Centre for AI in Media Proposal.docx
Reach Out and Touch Someone: Haptics and Empathic Computing
Unlocking AI with Model Context Protocol (MCP)
Big Data Technologies - Introduction.pptx
Approach and Philosophy of On baking technology
MYSQL Presentation for SQL database connectivity
Understanding_Digital_Forensics_Presentation.pptx
MIND Revenue Release Quarter 2 2025 Press Release
The Rise and Fall of 3GPP – Time for a Sabbatical?

Funcargs & other fun with pytest