Test & Code cover image

Test & Code

Latest episodes

undefined
May 21, 2021 • 32min

154: Don't Mock your Database - Jeff Triplett

You need tests for your web app. And it has a database. What do you do with the database during testing? Should you use the real thing? or mock it? Jeff Triplett says don't mock it. In this episode, we talk with Jeff about testing web applications, specifically Django apps, and of course talk about the downsides of database mocking. Full TranscriptSpecial Guest: Jeff Triplett.Sponsored By:Datadog: Modern end-to-end monitoring & security. See inside any stack, any app, at any scale, anywhere. Get started with a free trial at testandcode.com/datadog and Datadog will send you a free t-shirt. ConfigCat.com: Release features faster with less risk with ConfigCat. You can try it out with the forever free plan or get 25% off with code testandcode2021 Promo Code: testandcode2021Links:"🤔 In ~12 years, I have never seen a case where mocking a database was a good idea. ..." Django NewsMotoTest & Code 103: Django - Lacey Williams HenschelModel Bakery: Smart fixtures for better tests Faker
undefined
May 14, 2021 • 32min

153: Playwright for Python: end to end testing of web apps - Ryan Howard

Playwright is an end to end automated testing framework for web apps with Python support and even a pytest plugin. Full TranscriptSpecial Guest: Ryan Howard.Sponsored By:PyCharm Professional: Try PyCharm Pro for 4 months and learn how PyCharm will save you time. Promo Code: TESTANDCODE22Links:Playwright for PythonWhy Playwright?playwright-pytest
undefined
May 7, 2021 • 50min

152: Python Packaging - Brett Cannon

I always learn a lot when I talk to Brett, and this episode is no exception. We talk about the packaging workflow, tools, changes, pyproject.toml, flit, setuptools, and so much more. I hope you learn as much as I did in this great discussion. Full TranscriptSpecial Guest: Brett Cannon.Sponsored By:Datadog: Modern end-to-end monitoring & security. See inside any stack, any app, at any scale, anywhere. Get started with a free trial at testandcode.com/datadog and Datadog will send you a free t-shirt. Links:pytest-srcpathsPython Packaging User Guidepypa/packaging: Core utilities for Python packagesflit and requires-pythonExtending and Embedding the Python Interpreter — Python 3.9.2 documentationFlitsetuptoolsPEP 518 -- Specifying Minimum Build System Requirements for Python Projects | Python.orgPEP 517 -- A build-system independent format for source trees | Python.orgFlit editable installs with --symlink or --pth-filePEP 440 -- Version Identification and Dependency Specification | Python.orgSpecifying requires-python with flitwheelUniversal 1 binaryUniversal 2 binaryCython: C-Extensions for PythonCFFIpybind11: Seamless operability between C++11 and PythonCondaconda environmentsconda-forgeVaultsOfParnassus
undefined
Apr 28, 2021 • 57min

151: Python Adventure - Brandon Rhodes

Adventure, or Colossal Cave Adventure, was written between 1975 and 1977 in Fortran. Brandon Rhodes ported it to Python 3, initial release in 2011, and still maintains it. We talk to Brandon about this wonderful game. YOU ARE STANDING AT THE END OF A ROAD BEFORE A SMALL BRICK BUILDING. AROUND YOU IS A FOREST. A SMALL STREAM FLOWS OUT OF THE BUILDING AND DOWN A GULLY. >>> east A bit later... IT IS NOW PITCH DARK. IF YOU PROCEED YOU WILL LIKELY FALL INTO A PIT. >>> light(lamp) YOUR LAMP IS NOW ON. YOU ARE IN A DEBRIS ROOM FILLED WITH STUFF WASHED IN FROM THE SURFACE. A LOW WIDE PASSAGE WITH COBBLES BECOMES PLUGGED WITH MUD AND DEBRIS HERE, BUT AN AWKWARD CANYON LEADS UPWARD AND WEST. A NOTE ON THE WALL SAYS ... What's happening is that I'm playing adventure, which you can pip install thanks to Brandon Rohdes. Adventure is a faithful port to Python 3 from the original 1977 FORTRAN code by Crowther and Woods that lets you explore Colossal Cave, where others have found fortunes in treasure and gold, ... In this episode, we talk with Brandon Rhodes about this marvelous game. Full TranscriptSpecial Guest: Brandon Rhodes.Sponsored By:PyCharm Professional: Try PyCharm Pro for 4 months and learn how PyCharm will save you time. Promo Code: TESTANDCODE22Links:adventure · PyPIpython-adventure: Original Colossal Caves adventure game, but in Python 3Brandon Rhodes Personal SitePython Design Patternspyephem: Scientific-grade astronomy routines for Pythonpython-skyfield: Elegant astronomy for PythonAdventure in Python 3 - announcement blog post from 2012NetHackFTL: Faster Than LightPEP 517 -- A build-system independent format for source trees | Python.org
undefined
Apr 15, 2021 • 11min

150: A Practical Testing Strategy

Coming up with a testing strategy doesn't have to be stressful. Prioritizing features to test, and generating test cases for each feature can be fairly quick and painless. This episode covers a strategy for both that can be applied to many types of software. Full TranscriptSponsored By:PyCharm Professional: Try PyCharm Pro for 4 months and learn how PyCharm will save you time. Promo Code: TESTANDCODE22
undefined
Mar 31, 2021 • 50min

149: I don't test my code, "crappy Python" is all I write - Corey Quinn

Corey Quinn is the Chief Cloud Economist at The Duckbill Group. He's also a podcaster and writes a newsletter. And he also automates things with Python. But he doesn't write tests. Let's find out why. Reason for the interview. Rough summary of a twitter conversation: Corey: What podcasts should I try to get an invite onto? ToonArmyCaptain: Python Bytes, Test & Code, Talk Python Corey: But... I don't test my code, "crappy Python" is all I write, and I'd feel like a giant imposter. So yeah, I'd be game. link So here we are. This diagram is referenced in the show, the Last Week In AWS Newsletter Production Pipeline. Full TranscriptSpecial Guest: Corey Quinn.Sponsored By:PyCharm Professional: Try PyCharm Pro for 4 months and learn how PyCharm will save you time. Promo Code: TESTANDCODE22Links:Last Week in AWS
undefined
Mar 12, 2021 • 14min

148: Coverage.py and testing packages

How do you test installed packages using coverage.py? Also, a couple followups from last week's episode on using coverage for single file applications. Full TranscriptSponsored By:Linode: If it runs on Linux, it runs on Linode. Get started on Linode today with $100 in free credit for listeners of Test & Code.Links:episode 147: Testing Single File Python Applications/Scripts with pytest and coverageSpecifying source files — Coverage.py documentationTesting & Packaging - Hynekack
undefined
Mar 6, 2021 • 11min

147: Testing Single File Python Applications/Scripts with pytest and coverage

Have you ever written a single file Python application or script? Have you written tests for it? Do you check code coverage? This is the topic of this weeks episode, spurred on by a listener question. The questions: For single file scripts, I'd like to have the test code included right there in the file. Can I do that with pytest? If I can, can I use code coverage on it? The example code discussed in the episode: script.py def foo(): return 5 def main(): x = foo() print(x) if __name__ == '__main__': # pragma: no cover main() ## test code # To test: # pip install pytest # pytest script.py # To test with coverage: # put this file (script.py) in a directory by itself, say foo # then from the parent directory of foo: # pip install pytest-cov # pytest --cov=foo foo/script.py # To show missing lines # pytest --cov=foo --cov-report=term-missing foo/script.py def test_foo(): assert foo() == 5 def test_main(capsys): main() captured = capsys.readouterr() assert captured.out == "5\n" Suggestion by @cfbolz if you need to import pytest: if __name__ == '__main__': # pragma: no cover main() else: import pytest Full TranscriptSponsored By:PyCharm Professional: Try PyCharm Pro for 4 months and learn how PyCharm will save you time. Promo Code: TESTANDCODE22
undefined
Feb 28, 2021 • 49min

146: Automation Tools for Web App and API Development and Maintenance - Michael Kennedy

Building any software, including web apps and APIs requires testing. There's automated testing, and there's manual testing. In between that is exploratory testing aided by automation tools. Michael Kennedy joins the show this week to share some of the tools he uses during development and maintenance. We talk about tools used for semi-automated exploratory testing. We also talk about some of the other tools and techniques he uses to keep Talk Python Training, Talk Python, and Python Bytes all up and running smoothly. We talk about: Postman ngrok sitemap link testing scripts for manual processes using failover servers during maintenance, redeployments, etc gitHub webhooks and scripts to between fail over servers and production during deployments automatically floating IP addresses services to monitor your site: StatusCake, BetterUptime the affect of monitoring on analytics crash reporting: Rollbar, Sentry response times load testing: Locus Full TranscriptSpecial Guest: Michael Kennedy.Sponsored By:Linode: If it runs on Linux, it runs on Linode. Get started on Linode today with $100 in free credit for listeners of Test & Code.Links:Python Bytes PodcastTalk Python To Me PodcastTalk Python TrainingPostmanngrokStatusCakeBetter UptimeRollbarSentryLocust12 requests per second in Python
undefined
Feb 18, 2021 • 49min

145: For Those About to Mock - Michael Foord

A discussion about mocking in Python with the original contributor of unittest.mock, Michael Foord.Of course we discuss mocking and unittest.mock. We also discuss:testing philosophyunit testing and what a unit isTDDwhere Michael's towel is, and what colorMicheal was instrumental in the building of testing tools for Python, and continues to be a pragmatic source of honest testing philosopy in a field that has a lot of contradictory information.Links:unittest.mock - Python docsMocks Aren't Stubs - Martin Fowlerpytest-mockmock.patchAutospeccingArrange Act Asserttesting-in-python mailing listClassical and Mockist Testing — Classical and Mockist Testing Test First Programming / Test First Developmentepisode 102: Cosmic Python, TDD, testing and external dependencies - Harry Percivalepisode 132: mocking in Python - Anna-Lena Popkespytestunittest - Python docspytest assert usage30 best practices for software development and testing | Opensource.com

Get the Snipd
podcast app

Unlock the knowledge in podcasts with the podcast player of the future.
App store bannerPlay store banner

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode

Save any
moment

Hear something you like? Tap your headphones to save it with AI-generated key takeaways

Share
& Export

Send highlights to Twitter, WhatsApp or export them to Notion, Readwise & more

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode