Skip to main content

Testing hello world function in python with doctests

· 5 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Sometimes even the simplest programs deserve solid testing-especially when you're working in a team or trying to set strong standards for code quality. In this note, we'll take the most basic example-"Hello, World!"-and build out everything around it to demonstrate how doctests can be used effectively, even for something so trivial. The goal is to build intuition for testing, not just solve a toy problem.

Various Ways for Executing Doctests in Python

· 8 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Executing Doctests in Python: A Comprehensive Guide

Doctest is a module in the Python Standard Library that enables you to write tests within the documentation of your code-typically inside docstrings. These tests look like interactive Python sessions (as if they were run in a Python shell), and the doctest module verifies that the output matches the expected result. While doctests are generally simpler than unit tests written with unittest or pytest, they are powerful for checking that code examples in documentation remain correct over time.

This guide explores the various ways to execute doctests in Python, from running them via the command line to embedding them in code and running them programmatically.

How to Make Doctests Easy in Python with Gitpod and VS Code

· 6 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

If you're writing doctests in Python using Gitpod or VS Code, you don’t need much to get started. Python’s built-in doctest module lets you write examples in your function’s docstring using the familiar >>> prompt, and then run those examples as tests. This is great for small, focused functions or when you want your documentation to double as lightweight tests.

How to Easily Write Docstrings in Python Without a Headache (Using VSCode)

· 4 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Writing docstrings in Python can feel like a chore - especially with the odd formatting involving triple quotes, >>> signs, and parameter blocks. But clear, standardized docstrings are critical for both readability and maintainability.

If you’re using VSCode (Visual Studio Code), you’re in luck. With a few extensions and configurations, you can make writing professional, PEP 257-compliant docstrings painless.

What is Behaviour Driven Developement in Python

· 14 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

We're constantly striving for higher quality, faster delivery, and closer collaboration. In the realm of API development, where contracts and interactions are paramount, these goals often feel like a constant uphill battle. This is where Behavior-Driven Development (BDD) emerges not just as a testing methodology, but as a powerful paradigm for designing, developing, and validating robust Python API systems.

What is Design-First paradigm in Python

· 11 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

We've all seen projects spiral when API design is an afterthought. It's a common trap: dive straight into coding, then realize downstream that your API is clunky, inconsistent, and a nightmare to integrate with. This is precisely why the Design-First (API-First) paradigm isn't just a buzzword; it's a critical methodology for building scalable, maintainable, and truly collaborative API systems, especially within the Python ecosystem.

Test-Driven Development (TDD) - Writing Code That's Correct by Design

· 10 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Not only Shift-Left mantra matters

The mantra of "Shift Left" has echoed through the halls of software development for years now, and for good reason. The core idea is simple yet powerful: move testing, quality, and security considerations as early as possible in the development lifecycle. It's about catching problems when they're small and cheap to fix, not when they're gargantuan headaches in production. But as a lead engineer who's seen a few projects through the trenches, I've come to realize that "Shift Left" isn't the destination; it's the starting point.

To truly build robust, maintainable, and high-quality software, especially in a dynamic language like Python, we need to embrace a set of development paradigms that not only support but enhance the "Shift Left" philosophy. These aren't just buzzwords; they are methodologies that, when adopted, fundamentally change how we approach writing code for the better.