New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for dict/list/tuple attributes #18

Closed
rbarrois opened this Issue Jun 27, 2012 · 3 comments

Comments

Projects
None yet
3 participants
@rbarrois
Member

rbarrois commented Jun 27, 2012

See https://gist.github.com/3002546 :

This should work:

class MyFactory(factory.Factory):
  foo = {
    'a': factory.InfiniteIterator([1, 2, 3]),
  }

A good implementation would be:

class MyFactory(factory.Factory):
  foo = factory.DictFactory(a=factory.InfiniteIterator([1, 2, 3]))

  bar = factory.DictFactory({
    'a': factory.InfiniteIterator([1, 2, 3]),
  })
@harobed

This comment has been minimized.

Show comment
Hide comment
@harobed

harobed commented Jun 27, 2012

+1

@mvantellingen

This comment has been minimized.

Show comment
Hide comment
@mvantellingen

mvantellingen Jun 27, 2012

+1

We used the following which seems to work ok:

class DictFactory(factory.Factory):
    ABSTRACT_FACTORY = True
    _creation_function = (lambda self, **kwargs: kwargs,)

But that required a FACTORY_FOR = None on every factory

mvantellingen commented Jun 27, 2012

+1

We used the following which seems to work ok:

class DictFactory(factory.Factory):
    ABSTRACT_FACTORY = True
    _creation_function = (lambda self, **kwargs: kwargs,)

But that required a FACTORY_FOR = None on every factory

@harobed

This comment has been minimized.

Show comment
Hide comment
@harobed

harobed Jun 27, 2012

But that required a FACTORY_FOR = None on every factory

On every factory ? Some example ?

harobed commented Jun 27, 2012

But that required a FACTORY_FOR = None on every factory

On every factory ? Some example ?

@rbarrois rbarrois closed this in 2b661e6 Apr 15, 2013

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