Testing Python based application
$19.00
Minimum price
$29.00
Suggested price

Testing Python based application

About the Book

The book covers all aspects of testing a Python based application using Pytest.

It also covers some aspects using the unittest library to help the readers who need to use that.

About the Author

Gábor Szabó
Gábor Szabó

Gabor Szabo has been programming for more than 40 years in a number of languages and in various environments. He used to do DevOps before there was a name for it.

These days he usually helps companies improve their engineering practices by providing training, introducing test automation, CI, CD. Sometimes this includes building internal web sites. Gabor also loves explaining things and provides training to his clients.

He also has a number of websites. Each one using a different technology.

Gabor runs the Code Maven site and a number of its sub-site where he write about lots of different technologies such as Python, Rust, Git, Continuous Integration, etc.

Gabor has been writing Perl since 1995 and teaching it since 2000. He is the author of the Perl Maven site including the Perl Tutorial. He has taught web development with Perl Dancer many time including at Perl Conferences in Europe and USA. Gabor is the chief editor of the Perl Weekly newsletter.

Table of Contents

    • Thank you!
    • Testing
    • Traditional Organizations
    • Quality Assurance
    • Web age Organizations
    • TDD vs Testing as an Afterthought
    • Why test?
    • Testing Modes
    • Testing Applications
    • Testing What to test?
    • Testing in Python
    • Testing Environment
    • Testing Setup - Fixture
    • Testing Resources
    • Testing with unittest
    • Use a module
    • Test a module
    • The tested module
    • Testing - skeleton
    • Testing
    • Test examples
    • Testing with PyTest
    • Pytest features
    • Test methods
    • Pytest setup
    • Pytest - AUT - Application Under Test
    • How to use the module?
    • Pytest - simple passing test
    • Pytest failing test in one function
    • Pytest failing test separated
    • Pytest run all the test files
    • Exercise: test simple module
    • Pytest expected exception
    • Pytest a nice Fibonacci example
    • Pytest testing Fibonacci
    • Pytest expected exception
    • Pytest testing expected exception
    • Pytest Change the text of the exception
    • Pytest Missing exception
    • Pytest Other exception is raised
    • Pytest No exception is raised
    • Exercise: test more exceptions
    • Solution: test more exceptions
    • PyTest: Multiple Failures
    • PyTest: Multiple Failures output
    • PyTest Selective running of test functions
    • PyTest: stop on first failure
    • Pytest: expect a test to fail (xfail or TODO tests)
    • Pytest: expect a test to fail (xfail or TODO tests)
    • PyTest: show xfailed tests with -rx
    • Pytest: skipping tests
    • Pytest: show skipped tests with -rs
    • Pytest: show extra test summmary info with -r
    • Pytest: skipping tests output in verbose mode
    • Pytest verbose mode
    • Pytest quiet mode
    • PyTest print STDOUT and STDERR using -s
    • Exercise: test math functions
    • Exercise: test this app
    • Exercise: test the csv module
    • Solution: Pytest test math functions
    • Solution: Pytest test this app
    • Solution: test the csv module
    • PyTest using classes
    • Exercise: module
    • Exercise: Open Source
    • Parametrize PyTest with pytest.mark.parametrize
    • Parametrize PyTest with multiple parameters
    • Pytest and forking
    • Exercise: Write tests for script combining files
    • Solution: Write tests for script combining files
    • Pytest: Flask echo
    • Pytest: testing Flask echo
    • Pytest resources
    • Anagram on the command line
    • PyTest testing CLI
    • Pytest assert
    • PyTest failure reports
    • PyTest compare numbers
    • PyTest compare numbers relatively
    • PyTest compare strings
    • PyTest compare long strings
    • PyTest is one string in another strings
    • PyTest test any expression
    • PyTest element in list
    • PyTest compare short lists
    • PyTest compare short lists - verbose output
    • PyTest compare lists
    • PyTest compare dictionaries - different values
    • PyTest compare dictionaries - missing-keys
    • PyTest Fixtures
    • PyTest: What are Fixtures?
    • PyTest: test with functions
    • PyTest Fixture setup and teardown xUnit style
    • PyTest Fixture setup and teardown output
    • PyTest: Fixture Class setup and teardown
    • PyTest: Fixture Class setup and teardown output
    • What is Dependency injection?
    • Pytest fixture - tmpdir
    • Pytest and tempdir
    • Pytest CLI key-value store
    • Pytest testing key-value store - environment variable
    • Pytest testing key-value store - environment variable (outside)
    • Application that prints to STDOUT and STDERR
    • Pytest capture STDOUT and STDERR with capsys
    • PyTest - write your own fixture
    • Pytest Fixture - autouse fixtures
    • Share fixtures among test files: conftest.py
    • Manual fixtures (dependency injection)
    • Pytest Fixture providing value
    • Pytest Fixture providing value with teardown
    • Pytest create fixture with file(s) - app and test
    • Pytest create fixture with file(s) - helper function
    • Pytest create fixture with file(s) - fixture
    • Pytest with Docker - application
    • Pytest with Docker - test
    • Pytest with Docker - improved
    • Pytest fixture inject data
    • Pytest fixture for MongoDB
    • Pytest parameters
    • Pytest parametrized fixture
    • Pytest parametrized fixture with dependency injection
    • Pytest parametrized fixture to use Docker
    • Pytest Mocking
    • Pytest: Mocking - why?
    • Pytest: Mocking - what?
    • Pytest: What is Mocking? - Test Doubles
    • Pytest: Monkey Patching
    • Pytest: Hard-coded path
    • Pytest: Hard-coded path - manually replace attribute
    • Pytest: Hard-coded path - monkeypatch attribute
    • Pytest: Hard-coded path - monkeypatch attribute - tempdir
    • Pytest: Mocking slow external API call
    • Pytest: Mocking slow external API call - manually replace function
    • Pytest: Mocking slow external API call - manually replace function - broken remote
    • Pytest: Mocking slow external API call - monkeypatch
    • Pytest: Mocking STDIN
    • Pytest: Mocking STDIN manually mocking
    • Pytest: Mocking STDIN - monkeypatch
    • Pytest: Mocking random numbes - the application
    • Pytest: Mocking random numbes
    • Pytest: Mocking multiple random numbers
    • Pytest: Mocking environment variables
    • Pytest: Mocking time
    • Pytest: Mocking time (test expiration)
    • Pytest: mocking specific timestamp with datetime
    • Pytest: mocking specific timestamp with datetime
    • Pytest: mocking datetime.date.today
    • Pytest: mocking datetime date
    • Pytest: One dimensional spacefight
    • Pytest: Mocking input and output in the game
    • Pytest: Mocking input and output in the game - no tools
    • Pytest: Mocking random in the game
    • Pytest: Mocking random in the game - no tools
    • Pytest: Flask app sending mail
    • Pytest: Mocking Flask app sending mail
    • Pytest: Mocking - collecting stats example
    • Pytest command line options
    • PyTest: Run tests in parallel with xdist
    • PyTest: Order of tests
    • PyTest: Randomize Order of tests
    • PyTest: Force default order
    • PyTest test discovery
    • PyTest test discovery - ignore some tests
    • Pytest dry-run - collect-only
    • PyTest select tests by name
    • Pytest use markers to select tests
    • PyTest select tests by marker
    • No test selected
    • Pytest reporting in JUnit XML or JSON format
    • Pytest reporting in JUnit XML format
    • Pytest reporting in JSON format
    • Pytest JSON report
    • Add extra command line parameters to Pytest - conftest - getoption
    • Add extra command line parameters to Pytest - as a fixture
    • Add extra command line parameters to Pytest - used in the autouse fixtures
    • PyTest: Test Coverage
    • Pytest and flake8
    • Pytest and mypy
    • Pytest - other
    • Testing with Pytest
    • Testing functions
    • Testing class and methods
    • Pytest - execute
    • Pytest - execute
    • Pytest simple module to be tested
    • Pytest simple tests - success
    • Pytest simple tests - success output
    • Pytest simple tests - failure
    • Pytest simple tests - failure output
    • PyTest bank deposit
    • PyTest expected exceptions (bank deposit)
    • PyTest expected exceptions (bank deposit) - no exception happens
    • PyTest expected exceptions (bank deposit) - different exception is raised
    • PyTest expected exceptions - divide
    • PyTest expected exceptions output
    • PyTest expected exceptions (text changed)
    • PyTest expected exceptions (text changed) output
    • PyTest expected exceptions (other exception)
    • PyTest expected exceptions (other exception) output
    • PyTest expected exceptions (no exception)
    • PyTest expected exceptions (no exception) output
    • PyTest compare short lists - output
    • Testing Master Mind
    • Module Fibonacci
    • PyTest - assertion
    • PyTest - failure
    • PyTest - list
    • Pytest: monkeypatching time
    • PyTest: no random order
    • Testing Intro
    • The software testing equasion
    • The software testing equasion (fixed)
    • The pieces of your software?
    • Manual testing
    • What to tests?
    • Continuous Integration

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub