From 5692f64619bf009cf92bf0a8c6f77bf82f0e3d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Wed, 23 Dec 2020 17:59:47 +0100 Subject: [PATCH] Add a new regression testing module That module should hold all tests used when reproducing (and fixing) an issue. --- tests/test_regression.py | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/test_regression.py diff --git a/tests/test_regression.py b/tests/test_regression.py new file mode 100644 index 00000000..a9ea1c66 --- /dev/null +++ b/tests/test_regression.py @@ -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)