Skip to content

Commit

Permalink
Add a new regression testing module
Browse files Browse the repository at this point in the history
That module should hold all tests used when reproducing (and fixing) an
issue.
  • Loading branch information
rbarrois committed Dec 23, 2020
1 parent e19142c commit 5692f64
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/test_regression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright: See the LICENSE file.


"""Regression tests related to issues found with the project"""

import datetime
import typing as T
import unittest

import factory

# Example objects
# ===============


class Author(T.NamedTuple):
fullname: str
pseudonym: T.Optional[str] = None


class Book(T.NamedTuple):
title: str
author: Author


class PublishedBook(T.NamedTuple):
book: Book
published_on: datetime.date
countries: T.List[str]


class FakerRegressionTests(unittest.TestCase):
def test_locale_issue(self):
"""Regression test for `KeyError: 'locale'`
See #785 #786 #787 #788 #790 #796.
"""
class AuthorFactory(factory.Factory):
class Meta:
model = Author

class Params:
unknown = factory.Trait(
fullname="",
)

fullname = factory.Faker("name")

public_author = AuthorFactory(unknown=False)
self.assertIsNone(public_author.pseudonym)

unknown_author = AuthorFactory(unknown=True)
self.assertEqual("", unknown_author.fullname)

0 comments on commit 5692f64

Please sign in to comment.