pytest-factoryboy icon indicating copy to clipboard operation
pytest-factoryboy copied to clipboard

Fix of issue 218

Open mcosti opened this issue 1 year ago • 6 comments

https://github.com/pytest-dev/pytest-factoryboy/issues/218

This was the most backwards compatible way of implementing it that I could think of.

It works for my usecase scenario, but I am of course open to suggestions.

I would add testing but there are no tests involving Django models yet

mcosti avatar May 01 '24 10:05 mcosti

It seems like the fix is not complete.

Somewhere in the partial function model_fixture, the regular fixture name is called, and if the clashing factory does not have the same parameter, it will fail like this:

file /opt/project/tests/finance/subscriptions/test_prices_checkout.py, line 17
  def test_cancel_subscription(subscription: Subscription):
file /usr/local/lib/python3.11/dist-packages/pytest_factoryboy/fixture.py, line 350
  def model_fixture(request: SubRequest, factory_name: str) -> Any:
file /usr/local/lib/python3.11/dist-packages/pytest_factoryboy/fixture.py, line 502
  def subfactory_fixture(request: SubRequest, factory_class: FactoryType) -> Any:
E       fixture 'customer__id' not found

mcosti avatar May 01 '24 14:05 mcosti