factory.sequence seems broken for inherited factories. #93

Closed
Sheeprider opened this Issue Sep 16, 2013 · 2 comments

Comments

Projects
None yet
2 participants
@Sheeprider

Hello,
I've been using factories a lot for my tests, and they have been a great help,
but I think I found a bug on sequence generation in case of inherited models and inherited factories.

With these models :

#models.py (I'm using Django)
from django.db import models

class A(models.Model):
    name = models.TextField(max_length=10)

class B(A):
    pass

And these factories :

#factories.py
import factory

from . import models

class AFactory(factory.Factory):  # same behavior with factory.django.DjangoModelFactory
    FACTORY_FOR = models.A
    name = factory.Sequence(lambda n: u'User {0}'.format(n))

class BFactory(AFactory):
    FACTORY_FOR = models.B

I get the following :

>>> from . import factories
>>> factories.AFactory().name
u'User 0'
>>> factories.AFactory().name
u'User 1'
>>> factories.BFactory().name
u'User 2'
>>> factories.AFactory().name
u'User 2'  # I expected: u'User 3'

Using factory-boy 2.1.2.

@rbarrois rbarrois closed this in 7fe9dca Sep 16, 2013

@Sheeprider

This comment has been minimized.

Show comment
Hide comment
@Sheeprider

Sheeprider Sep 17, 2013

That was fast !
Thanks 👍

That was fast !
Thanks 👍

@rbarrois

This comment has been minimized.

Show comment
Hide comment
@rbarrois

rbarrois Sep 17, 2013

Member

@Sheeprider You're welcome :)
And thanks for helping me discover a second, sneakier issue with sequence counters !

Member

rbarrois commented Sep 17, 2013

@Sheeprider You're welcome :)
And thanks for helping me discover a second, sneakier issue with sequence counters !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment