Comments (13)
@sliverc what's models.Attachment? is it just a dict?
from pytest-factoryboy.
No it is a simple django model.
class Attachment(models.Model):
path = models.ImageField(max_length=1024)
I think the problem is caused through a factory boy change where ImageField
resp. FileField
is now derived from a declarations.Dict
class.
See https://github.com/FactoryBoy/factory_boy/blob/master/factory/django.py#L175
from pytest-factoryboy.
@sliverc I see.. wow.. in factoryboy 2.10.0 ImageField is a SubFactory now, more than that - subclass of a Dict, this what brings the "dict" as a name of it's model. Not sure what kind of sense does it make.
Initially my idea was that SubFactory points to a factory of a model, for which you need a fixture.
from pytest-factoryboy.
Basically this:
import factory
from pytest_factoryboy import register
class Foo(dict):
pass
@register
class FooFactory(factory.Factory):
class Meta:
model = Foo
bar = factory.declarations.Dict({})
def test_foo(foo):
"""this test will lead to `fixture 'dict' not found` error."""
pass
from pytest-factoryboy.
@sliverc We could fix it by comparing a type of the declaration. This would have an implication that people can't subclass SubFactory or RelatedFactory to refer to other models anymore.
Let's add an issue in factory-boy and ask what do they think why ImageField has to be a SubFactory.
from pytest-factoryboy.
I also don't quite see why it needs to be a subclass of SubFactory. Let's see what upstream has to say I guess.
from pytest-factoryboy.
Hi !
Is there any news or workaround for this one ?
from pytest-factoryboy.
@noirbizarre have you tried? I see Rafael has closed the issue FactoryBoy/factory_boy#451
from pytest-factoryboy.
@sliverc is it still an issue? can be closed?
from pytest-factoryboy.
I have tested it with the factory boy master and it works as expected. Thanks.
The only problem is that the factory boy change is not released yet so factory boy git master needs to be added as dependency for this to work.
I am fine with that and this issue can be closed. Question is whether others will still stumble upon this issue till factory boy has an official release with this fix.
from pytest-factoryboy.
I tried but on latest public release. If this is working with the master, it's fine to me and I'll wait for the release
from pytest-factoryboy.
Factory Boy has been released and I have tested it with version 2.11.1
. It works so closing this issue. @olegpidsadnyi Thanks for having worked on this.
from pytest-factoryboy.
@sliverc This is actually still problematic when using factory.Dict
and factory.List
, as they are also subfactories... :-/
from pytest-factoryboy.
Related Issues (20)
- Fix tests/test_postgen_dependencies::test_postgen_related
- AttributeError using `LazyFixture` in `register()` HOT 5
- Parent factory model name disregards `_name` override. HOT 1
- Ship tests with source distribution HOT 1
- function uses no argument HOT 1
- UserWarning: UserWarning: Using a <class 'list'> as model type for <ListFactory for <class 'list'>> is discouraged HOT 5
- Error `fixture not found` if define `register(_name=)` for connected SubFactory which is connected with another SubFactory HOT 1
- DeprecationWarning with pytest 7.2.0 HOT 4
- PytestAssertRewriteWarning
- Feature request: override name of factory fixture? HOT 3
- Alternative for `register`
- register with type hints HOT 3
- Improve handling of `factory.Maybe`
- Request other fixtures in fixtures generated by register HOT 3
- How can I pass function-scope fixtures (e.g. db sessions) to each Factory in combination with pytest-asyncio?
- Question regarding of usage of LazyFixture in @pytest.mark.parametrize on alias instead of chained fixture. HOT 1
- Broken support for Python 3.7 HOT 1
- 2.7.0: missing git version tag
- factory.SubFactory fixture collision when the model has the same name HOT 6
- `Trait`s not being considered by pytest_factoryboy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-factoryboy.