Closed PoByBolek closed 1 year ago
Nice catch! Do you think this could be a fix?
if field.unique and not (isinstance(fixture, (DynamicFixture, Copier, DataFixture, Mask)) or callable(fixture)):
instead of
if field.unique and not (isinstance(fixture, (DynamicFixture, Copier, DataFixture)) or callable(fixture)):
This would fix my issue at hand, yes 👍
So this is only in test code?
Any progress on this? I'd be happy to provide a pull request for this if you don't have time right now...
Any progress on this? I'd be happy to provide a pull request for this if you don't have time right now...
That would be great! Then I can generate a new release.
Thanks guys. I released the 3.1.3 version, but it was the first time using Twine for that, so if there is any problem with that release, please let me know.
I am planning to release a 4.0.0 version later discarding support for Python 2 and old Django versions. That should clean up the code to facilitate new contributions.
I have a class with a unique field that I want to fill using string masks in my tests. For example:
But when I try to run the tests using
python manage.py test
this raises the following exception (even though the string mask is not a static value):However, when I remove the
unique=True
constraint, everything works perfectly fine and the test (G(Person).name != G(Person).name
) succeeds.I feel like
DynamicFixture.teach()
should also allow string masks here.https://github.com/paulocheque/django-dynamic-fixture/blob/ce0d3deb895360ec2b57b98037a13573967c94f6/django_dynamic_fixture/ddf.py#L682-L691
I currently work around this using a lambda expression, but allowing a string mask directly would be much nicer 😸