r/learnpython • u/uzuis_4thwife • Oct 21 '26
Need help with building tests and understanding OOP design patterns
I am a post-bacc student currently in a Python for Web API online course. We just wrapped up our calculator application unit, where we learned how to build comprehensive dynamic tests using OOP design patterns. However, I finished the unit a lot more lost than when I started. Building parameterized tests still puzzles me, especially whenever I'm building the majority of a test from scratch rather than fixing minor errors in the code. Even when I do use AI to help me work through my assignments, none of it really sticks. Most of the time, I feel like I'm copying and pasting code whenever mine is incorrect and not really learning.
What are resources that you all would recommend for learning how to build application tests and files with OOP concepts? Any online resources with interactive, hands-on lessons would be greatly appreciated.
View all comments
2
u/Financial_Morning386 Oct 21 '26
The parameterized-tests struggle is a really common one, and honestly it usually clicks once you see what pytest is doing under the hood with them. I'll assume your course was using pytest's @pytest.mark.parametrize — if so, the mental model is just "one test function, pytest runs it N times, each with a different argument tuple, and each run is reported as its own test." Writing a couple of those by hand for your calculator class (valid inputs, edge cases like division by zero, invalid input) is a great drill.
A few things that helped me when I was bridging the gap from "unit tests on small functions" to "tests on an actual application":
For resources, genuinely interactive/hands-on:
Since your course is about web APIs: once you cover FastAPI/Flask, both have a TestClient that lets you send fake HTTP requests to your app in tests without running a server. That's where testing suddenly feels "real" — you're testing the same classes, just through the API layer.
Skip the AI for a bit on these exercises, as the other commenter said — the struggle of building a parametrized test from scratch is exactly what makes it stick.