# Keeping Tests DRY with Class Based Tests In Python

DevFeed: [Keeping Tests DRY with Class Based Tests In Python](<https://devfeed.tech/articles/keeping-tests-dry-with-class-based-tests-in-python-33916.md>)

Original publisher: [Read original article](<https://hakibenita.com/keeping-tests-dry-with-class-based-tests-in-python>)

Author: Haki Benita

Published: 2016-08-19T21:00:00Z

Content type: tutorial

Language: en

Sources: [Haki Benita](<https://devfeed.tech/sources/haki-benita.md>)

Topics: [Testing](<https://devfeed.tech/topics/testing.md>), [Python](<https://devfeed.tech/topics/python.md>), [API](<https://devfeed.tech/topics/api.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [articles](<https://devfeed.tech/tags/articles.md>), [class](<https://devfeed.tech/tags/class.md>), [django](<https://devfeed.tech/tags/django.md>), [python](<https://devfeed.tech/tags/python.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tests](<https://devfeed.tech/tags/tests.md>)

## AI overview

This tutorial presents a class-based approach to writing and maintaining DRY tests in Python. It defines goals for extensive, expressive, and maintainable tests, then applies the approach to an API login endpoint with multiple scenarios, inputs, expected outputs, status codes, and side effects.

## Source excerpt

Tests can be a bummer to write but even a bigger nightmare to maintain. When we noticed we are putting off simple tasks just because we were afraid to update some monster test case, we started looking for more creative ways to simplify the process of writing and maintaining tests. In this article I will describe a class based approach to writing tests.