-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/introduce-mypy-and-isort
- Loading branch information
Showing
10 changed files
with
195 additions
and
29 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
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
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,15 @@ | ||
# How to make a release | ||
|
||
```shell | ||
python -m pip install --upgrade build twine | ||
|
||
# cleanup the ./dist folder | ||
rm -rf ./dist | ||
|
||
# Build the distributions | ||
python -m build | ||
|
||
# Upload them | ||
|
||
twine check dist/* && twine upload dist/* | ||
``` |
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
"""pytest-factoryboy public API.""" | ||
from .fixture import register, LazyFixture | ||
|
||
__version__ = "2.1.0" | ||
__version__ = "2.2.0" | ||
|
||
|
||
__all__ = ("register", "LazyFixture") |
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
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
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
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,62 @@ | ||
from dataclasses import dataclass | ||
|
||
import pytest | ||
from _pytest.fixtures import FixtureLookupError | ||
from factory import Factory | ||
|
||
from pytest_factoryboy import register | ||
|
||
|
||
@dataclass | ||
class Foo: | ||
value: str | ||
|
||
|
||
@register | ||
class FooFactory(Factory): | ||
class Meta: | ||
model = Foo | ||
|
||
value = "module_foo" | ||
|
||
|
||
def test_module_namespace(foo): | ||
assert foo.value == "module_foo" | ||
|
||
|
||
class TestClassNamespace: | ||
@register | ||
class FooFactory(Factory): | ||
class Meta: | ||
model = Foo | ||
|
||
value = "class_foo" | ||
|
||
register(FooFactory, "class_foo") | ||
|
||
def test_class_namespace(self, class_foo, foo): | ||
assert foo.value == class_foo.value == "class_foo" | ||
|
||
class TestNestedClassNamespace: | ||
@register | ||
class FooFactory(Factory): | ||
class Meta: | ||
model = Foo | ||
|
||
value = "nested_class_foo" | ||
|
||
register(FooFactory, "nested_class_foo") | ||
|
||
def test_nested_class_namespace(self, foo, nested_class_foo): | ||
assert foo.value == nested_class_foo.value == "nested_class_foo" | ||
|
||
def test_nested_class_factories_dont_pollute_the_class(self, request): | ||
with pytest.raises(FixtureLookupError): | ||
request.getfixturevalue("nested_class_foo") | ||
|
||
|
||
def test_class_factories_dont_pollute_the_module(request): | ||
with pytest.raises(FixtureLookupError): | ||
request.getfixturevalue("class_foo") | ||
with pytest.raises(FixtureLookupError): | ||
request.getfixturevalue("nested_class_foo") |
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