question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Register factory fixture name

See original GitHub issue

Could you provide a way to register a factory fixture with a different name?

Maybe something like register(ExampleFactory, factory_name="my_example_factory")

I tried the following but it still uses example_factory as the fixture name:

from myapp.factories import ExampleFactory as MyExampleFactory
register(MyExampleFactory)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
skarzicommented, May 13, 2021

register() function creates 2 fixtures:

  1. factory class fixture - auto-generated from factory_class.__name__
  2. model instance fixture - custom value can be used by setting _name parameter

Maybe I am wrong, but I thought this issue is about using a custom name for the factory class (point 1.) fixture.

0reactions
youtuxcommented, Jun 11, 2022

I’ll consider this solved then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Welcome to pytest-factoryboy's documentation! — pytest ...
Library exports a function to register factories as fixtures. ... The fixture name convention is to use the lowercase-underscore form of the class...
Read more >
SubFactory uses wrong fixture name when factory class ...
This gist demonstrates a failing test where the generated SubFactory fixture is expecting to find a b_model__name fixture when the one available ...
Read more >
python - Why would a pytest factory as fixture be used over ...
A factory fixture allows much more composability: e.g. you can make use of any other fixtures here (local injection, the test is agnostic...
Read more >
pytest fixtures: explicit, modular, scalable
fixtures have explicit names and are activated by declaring their use from test functions, modules, classes or whole projects. fixtures are implemented in...
Read more >
pytest-factoryboy
Factory fixtures allow using factories without importing them. The fixture name convention is to use the lowercase-underscore form of the class name. import ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found