-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
That module should hold all tests used when reproducing (and fixing) an issue.
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |