Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 831207fd435b47aeffdf6af853097e64322b4d44 # frozen: 25.12.0
rev: ea488cebbfd88a5f50b8bd95d5c829d0bb76feb8 # frozen: 26.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
Expand All @@ -26,7 +26,7 @@ repos:
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/python-poetry/poetry
rev: "b9e5d79fc57de2f2e60973019d56662b7398440b" # frozen: 2.2.1
rev: "a84cd0f1bedb5769ef6ef7389d8ee99b93b9ba4c" # frozen: 2.3.2
hooks:
- id: poetry-check
args: ["--lock"]
24 changes: 8 additions & 16 deletions tests/test_model_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ def test_named_model():


def test_generic_model_with_custom_name_no_warning(testdir):
testdir.makepyfile(
"""
testdir.makepyfile("""
from factory import Factory
from pytest_factoryboy import named_model, register

Expand All @@ -85,15 +84,13 @@ class Meta:
def test_payload(json_payload: dict):
assert isinstance(json_payload, dict)
assert json_payload["foo"] == "bar"
"""
)
""")
result = testdir.runpytest("-Werror") # Warnings become errors
assert_outcomes(result, passed=1)


def test_generic_model_name_raises_warning(testdir):
testdir.makepyfile(
"""
testdir.makepyfile("""
import builtins
from factory import Factory
from pytest_factoryboy import register
Expand All @@ -108,8 +105,7 @@ class Meta:
def test_payload(dict):
assert isinstance(dict, builtins.dict)
assert dict["foo"] == "bar"
"""
)
""")
result = testdir.runpytest()
assert_outcomes(result, passed=1)
result.stdout.fnmatch_lines(
Expand All @@ -118,8 +114,7 @@ def test_payload(dict):


def test_generic_model_with_register_override_no_warning(testdir):
testdir.makepyfile(
"""
testdir.makepyfile("""
from factory import Factory
from pytest_factoryboy import named_model, register

Expand All @@ -134,15 +129,13 @@ def test_payload(json_payload: dict):
assert isinstance(json_payload, dict)
assert json_payload["foo"] == "bar"

"""
)
""")
result = testdir.runpytest("-Werror") # Warnings become errors
assert_outcomes(result, passed=1)


def test_using_generic_model_name_for_subfactory_raises_warning(testdir):
testdir.makepyfile(
"""
testdir.makepyfile("""
import builtins
from factory import Factory, SubFactory
from pytest_factoryboy import register
Expand All @@ -166,8 +159,7 @@ class Meta:

def test_payload(http_request):
assert http_request.json["foo"] == "bar"
"""
)
""")

result = testdir.runpytest()
assert_outcomes(result, errors=1)
Expand Down
Loading