SlideShare a Scribd company logo
doctest Testing through documentation Honggang Wang @ Aragon Nov 2010
Getting Started # foo.py
def multiply(a, b):
“””
This is a demo function.
>>> multiply(3, 4)
12
>>> multiply('a', 5)
'aaaaa'
“””
return a * b $ python foo.py
$ python -v foo.py
$ python -m doctest -v foo.py
Trying:
multiply(3, 4)
Expecting:
12
ok
...
2 passed and 0 failed.
Ad

Recommended

Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Ilya Grigorik
 
An Introduction to Solr
An Introduction to Solr
tomhill
 
Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Park
pointstechgeeks
 
How Xslate Works
How Xslate Works
Goro Fuji
 
HTTP and Your Angry Dog
HTTP and Your Angry Dog
Ross Tuck
 
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
Fernando Hamasaki de Amorim
 
PHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & Pinba
Patrick Allaert
 
typemap in Perl/XS
typemap in Perl/XS
charsbar
 
Elegant concurrency
Elegant concurrency
Mosky Liu
 
The Ring programming language version 1.8 book - Part 45 of 202
The Ring programming language version 1.8 book - Part 45 of 202
Mahmoud Samir Fayed
 
JFokus 50 new things with java 8
JFokus 50 new things with java 8
José Paumard
 
Unit Testing Lots of Perl
Unit Testing Lots of Perl
Workhorse Computing
 
Test::Base
Test::Base
Tatsuhiko Miyagawa
 
Lambdas and Streams Master Class Part 2
Lambdas and Streams Master Class Part 2
José Paumard
 
Effective Benchmarks
Effective Benchmarks
Workhorse Computing
 
Bringing modern PHP development to IBM i (ZendCon 2016)
Bringing modern PHP development to IBM i (ZendCon 2016)
James Titcumb
 
Implementing pattern-matching in JavaScript (short version)
Implementing pattern-matching in JavaScript (short version)
François-Guillaume Ribreau
 
On UnQLite
On UnQLite
charsbar
 
Advanced Perl Techniques
Advanced Perl Techniques
Dave Cross
 
Java SE 8 for Java EE developers
Java SE 8 for Java EE developers
José Paumard
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Masahiro Nagano
 
PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012
Tim Bunce
 
Use PEG to Write a Programming Language Parser
Use PEG to Write a Programming Language Parser
Yodalee
 
Python在豆瓣的应用
Python在豆瓣的应用
Qiangning Hong
 
50 new things we can do with Java 8
50 new things we can do with Java 8
José Paumard
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPAN
charsbar
 
Python高级编程(二)
Python高级编程(二)
Qiangning Hong
 
Intro To Spring Python
Intro To Spring Python
gturnquist
 
Test driven development_for_php
Test driven development_for_php
Lean Teams Consultancy
 
Intro to Testing in Zope, Plone
Intro to Testing in Zope, Plone
Quintagroup
 

More Related Content

What's hot (20)

Elegant concurrency
Elegant concurrency
Mosky Liu
 
The Ring programming language version 1.8 book - Part 45 of 202
The Ring programming language version 1.8 book - Part 45 of 202
Mahmoud Samir Fayed
 
JFokus 50 new things with java 8
JFokus 50 new things with java 8
José Paumard
 
Unit Testing Lots of Perl
Unit Testing Lots of Perl
Workhorse Computing
 
Test::Base
Test::Base
Tatsuhiko Miyagawa
 
Lambdas and Streams Master Class Part 2
Lambdas and Streams Master Class Part 2
José Paumard
 
Effective Benchmarks
Effective Benchmarks
Workhorse Computing
 
Bringing modern PHP development to IBM i (ZendCon 2016)
Bringing modern PHP development to IBM i (ZendCon 2016)
James Titcumb
 
Implementing pattern-matching in JavaScript (short version)
Implementing pattern-matching in JavaScript (short version)
François-Guillaume Ribreau
 
On UnQLite
On UnQLite
charsbar
 
Advanced Perl Techniques
Advanced Perl Techniques
Dave Cross
 
Java SE 8 for Java EE developers
Java SE 8 for Java EE developers
José Paumard
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Masahiro Nagano
 
PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012
Tim Bunce
 
Use PEG to Write a Programming Language Parser
Use PEG to Write a Programming Language Parser
Yodalee
 
Python在豆瓣的应用
Python在豆瓣的应用
Qiangning Hong
 
50 new things we can do with Java 8
50 new things we can do with Java 8
José Paumard
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPAN
charsbar
 
Python高级编程(二)
Python高级编程(二)
Qiangning Hong
 
Intro To Spring Python
Intro To Spring Python
gturnquist
 
Elegant concurrency
Elegant concurrency
Mosky Liu
 
The Ring programming language version 1.8 book - Part 45 of 202
The Ring programming language version 1.8 book - Part 45 of 202
Mahmoud Samir Fayed
 
JFokus 50 new things with java 8
JFokus 50 new things with java 8
José Paumard
 
Lambdas and Streams Master Class Part 2
Lambdas and Streams Master Class Part 2
José Paumard
 
Bringing modern PHP development to IBM i (ZendCon 2016)
Bringing modern PHP development to IBM i (ZendCon 2016)
James Titcumb
 
Implementing pattern-matching in JavaScript (short version)
Implementing pattern-matching in JavaScript (short version)
François-Guillaume Ribreau
 
On UnQLite
On UnQLite
charsbar
 
Advanced Perl Techniques
Advanced Perl Techniques
Dave Cross
 
Java SE 8 for Java EE developers
Java SE 8 for Java EE developers
José Paumard
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Masahiro Nagano
 
PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012
Tim Bunce
 
Use PEG to Write a Programming Language Parser
Use PEG to Write a Programming Language Parser
Yodalee
 
Python在豆瓣的应用
Python在豆瓣的应用
Qiangning Hong
 
50 new things we can do with Java 8
50 new things we can do with Java 8
José Paumard
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPAN
charsbar
 
Python高级编程(二)
Python高级编程(二)
Qiangning Hong
 
Intro To Spring Python
Intro To Spring Python
gturnquist
 

Similar to using python module: doctest (20)

Test driven development_for_php
Test driven development_for_php
Lean Teams Consultancy
 
Intro to Testing in Zope, Plone
Intro to Testing in Zope, Plone
Quintagroup
 
Testing My Patience
Testing My Patience
Adam Lowry
 
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
kwatch
 
Groovy
Groovy
Zen Urban
 
Java Boilerplate Busters
Java Boilerplate Busters
HamletDRC
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicate
Kiev ALT.NET
 
SDC - Einführung in Scala
SDC - Einführung in Scala
Christian Baranowski
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4
Emil Vladev
 
Scala introduction
Scala introduction
Alf Kristian Støyle
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
Guillaume Laforge
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
Muthu Vinayagam
 
Round PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing Functionally
Sean Cribbs
 
Introduction to Client-Side Javascript
Introduction to Client-Side Javascript
Julie Iskander
 
Post Sharp Talk
Post Sharp Talk
willmation
 
Java operators
Java operators
Shehrevar Davierwala
 
Navigating the xDD Alphabet Soup
Navigating the xDD Alphabet Soup
Dror Helper
 
Java Script Workshop
Java Script Workshop
Dmitry Baranovskiy
 
Introduction to Protractor
Introduction to Protractor
Jie-Wei Wu
 
Javascript Primer
Javascript Primer
Adam Hepton
 
Intro to Testing in Zope, Plone
Intro to Testing in Zope, Plone
Quintagroup
 
Testing My Patience
Testing My Patience
Adam Lowry
 
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
kwatch
 
Java Boilerplate Busters
Java Boilerplate Busters
HamletDRC
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicate
Kiev ALT.NET
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
Guillaume Laforge
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
Muthu Vinayagam
 
Round PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing Functionally
Sean Cribbs
 
Introduction to Client-Side Javascript
Introduction to Client-Side Javascript
Julie Iskander
 
Post Sharp Talk
Post Sharp Talk
willmation
 
Navigating the xDD Alphabet Soup
Navigating the xDD Alphabet Soup
Dror Helper
 
Introduction to Protractor
Introduction to Protractor
Jie-Wei Wu
 
Javascript Primer
Javascript Primer
Adam Hepton
 
Ad

Recently uploaded (20)

UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
The Future of Product Management in AI ERA.pdf
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Mastering AI Workflows with FME by Mark Döring
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
The Future of Product Management in AI ERA.pdf
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Mastering AI Workflows with FME by Mark Döring
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
Ad

using python module: doctest