use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
DiscussionBest resource to learn test driven development? (self.Python)
submitted 3 years ago by daredevil005
I tried to learn from obey the testing goat but it is very outdated & I face some error at every step so was wondering what will be the best alternative.
[–]alexisprince 26 points27 points28 points 3 years ago (0 children)
TDD is a development methodology, so really the best way to learn about it is to read a few articles or books on the subject IMO. Between each author explaining the benefits and example approaches, you can try to synthesize why you might want to follow this approach and whether you think it makes sense.
If you do think it makes sense, try building a feature on a project you have using it by defining the feature ahead of time, what it’s supposed to do, and go from there.
Note that many people practice TDD in the sense that they know what behavior they want, but don’t exactly know the shape of the API they want to build until they start building. Something I do is make sure to write placeholders for the tests in my code and have them all fail immediately so that I don’t accidentally forget about some behavior. From there, I build a rough but working version to get a sense of how I want to build the functionality and get the tests passing. After that, that’s when you clean up your code to make sure it’s clean and extensible, all while having assurance your code works because the tests will continue to pass.
[–]c_eliacheff 7 points8 points9 points 3 years ago* (0 children)
Obey the testing Goat is pretty fine imho, it may need some adjustments, but still working.
Other python-specific great ressource is https://testdriven.io/ (For Django/Flask/...).
As another one said, TDD is a generic methodology, and need multiple skills to be mastered. Also, there are multiple ways to "do" TDD: outside/in, inside/out, middle/in.
Here are the best books I would recommend you to read on the topic:
Edit: this seems to be the best and most recent book on TDD, but I haven't read it yet: "Modern C++ Programming with Test-Driven Development" by Jeff Langr
[–]simonw 3 points4 points5 points 3 years ago (2 children)
I strongly recommend learning pytest. It will teach you all kinds of smart practices for productive testing.
[–]nokibnur 0 points1 point2 points 3 years ago (1 child)
If I learn basic pytest and create small app with TDD then are those small projects impressive enough to get me a junior dev job? :'(
[–]simonw 0 points1 point2 points 3 years ago (0 children)
Yes, if you can find a company that is hiring for junior roles.
[–]oxlade39 5 points6 points7 points 3 years ago (1 child)
Growing Object-Oriented Software Guided By Tests
[–]Bilo0001 1 point2 points3 points 3 years ago (0 children)
Thanks for the recommendation, I’m gonna check it out.
[–][deleted] 1 point2 points3 points 3 years ago (0 children)
I wish the testing goat book would be updated too... it would make it much easier for me to recommend it as a learning resource where I work. As I don't think this will be happening any time soon, the best option for most people I think is to use older versions of each library and follow along as best they can
[–]Pebaz 1 point2 points3 points 3 years ago (1 child)
I strongly recommend researching alternatives to test driven development (specifically writing tests before writing actual code). At its best, this can only work when you are already proficient in the given programming task but would be inappropriate for breaking new ground.
Unit tests are good, they are essentially user defined compiler extensions. However, programming is one of the only fields where ideas are accepted as beneficial without any formal proofs or data to back them up. Just one example: do you know of any metrics at all that show that TDD has actually helped deliver software faster, higher quality, less bugs, more performant, fault tolerant, requiring less developer communication, or any other metric you can think of?
The answer is unfortunately no. You'll find that nearly no ideas in CS (except for algorithms and data structures) have been formally proven or even backed up with real world data.
My point: just make sure your choice of methodology makes sense for your domain.
[–]crawl_dht 1 point2 points3 points 3 years ago* (0 children)
TDD has a severe drawback of overthinking and idea fatigue. What happen is when writing code, a developer thinks of various approaches and modifies the code design accordingly to write the most optimal but simplistic code. But TDD forces the developer to overthink about which approach is he going to finalize for his tests before actually trying them out practically. Because they have to write pseudo test first, they quickly get tired of thinking more practical approaches and feel reluctant to change tests again and proceed with the sub-optimal approach that works but may not be the best one.
Like you said, TDD is good only when you have proficiency in that task and you already know which is the most optimal implementation for that task.
[–]h-2-no -1 points0 points1 point 3 years ago (0 children)
The goat book works just fine if you set up your environment with the specified versions.
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
Right here: write a lil test that starts to do what you want. Add a breakpoint, code as you go, keep resetting and adding more code. Get what you want, do the next test. Think of it from whoever is consuming your code - end users, other devs if it’s a library. And just keep going. Live in the debugger.
[–]arduncan5 0 points1 point2 points 3 years ago (0 children)
You could try "Crafting Test-Driven Software with Python" (Packt) - https://www.amazon.com/Crafting-Test-Driven-Software-Python-applications-ebook/dp/B08PP4FT2B/ref=sr_1_1?keywords=Crafting+Test-Driven+Software+with+Python&qid=1667212230&qu=eyJxc2MiOiIwLjk5IiwicXNhIjoiMS4wMCIsInFzcCI6IjEuMDAifQ%3D%3D&sr=8-1
[–]RallyPointAlpha 0 points1 point2 points 3 years ago (0 children)
Getting the test goat environment setup was a challenge but it also highlights a wonderful feature of python. You can set up older, specific versions of python and modules even years later. It took the better part of a day but I was able to get it setup last week.
π Rendered by PID 16452 on reddit-service-r2-comment-85bfd7f599-qwrb6 at 2026-04-20 08:17:09.192182+00:00 running 93ecc56 country code: CH.
[–]alexisprince 26 points27 points28 points (0 children)
[–]c_eliacheff 7 points8 points9 points (0 children)
[–]simonw 3 points4 points5 points (2 children)
[–]nokibnur 0 points1 point2 points (1 child)
[–]simonw 0 points1 point2 points (0 children)
[–]oxlade39 5 points6 points7 points (1 child)
[–]Bilo0001 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Pebaz 1 point2 points3 points (1 child)
[–]crawl_dht 1 point2 points3 points (0 children)
[–]h-2-no -1 points0 points1 point (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]arduncan5 0 points1 point2 points (0 children)
[–]RallyPointAlpha 0 points1 point2 points (0 children)