Code Monkey home page Code Monkey logo

Comments (5)

Mappboy avatar Mappboy commented on September 16, 2024 1

Just a head's up I had a similar issue. The first error:

AttributeError: 'module' object has no attribute 'extensions'
In my case was because I was testing with out setting the application context.

with app.app_context():
    country = mixer.blend(Country)

The second issue:

AttributeError: Mixer (<class 'models.Country'>): 'NoneType' object has no attribute 'bases'.
Is most likely because the Country model contains a field not in the standard Sqlalchemy GenFactory. In my case (missing postgresql dialects UUID and ARRAY) this was resolved by creating a new factory for the missing fields.

def get_extents_array():
    """
    Generate a random extents array
    """
    return [0,1,0,1]

class SeerFactory(GenFactory):
    generators = {
        UUID: uuid4().__str__,
        (db.ARRAY, ARRAY): get_extents_array
    }
mixer = Mixer(commit=True, factory=SeerFactory)

This could be potentially made more clear in the GenFactory(mixer/ factory.py) classmethod get_fabric. If the field type doesn't exist fcls will equal None and therefore will not have a bases attribute. I'm not knowledgable enough about the code base to suggest a fix for it. But it should probably be a little more verbose about what field it doesn't have in the factory. I guess it's maybe worthwhile having and assert fcls is not None.

Offending piece of code at line 172 of factory.py.

# this will not work if fcls is None
if not func and fcls.__bases__:
    func = cls.generators.get(fcls.__bases__[0])

I hope that helps.

from mixer.

hussaintamboli avatar hussaintamboli commented on September 16, 2024

I also tried the Mixer class from mixer.backend.flask

from mixer.backend.flask import Mixer
mixer = Mixer(app, commit=True) 

It gives me a new error

AttributeError: Mixer (<class 'models.Country'>): 'NoneType' object has no attribute '__bases__'

from mixer.

rmrio avatar rmrio commented on September 16, 2024

Hi hussaintamboli
Did you resolve the issue?

from mixer.

hussaintamboli avatar hussaintamboli commented on September 16, 2024

I ended up using just Faker instead. I'll try to reproduce this issue when I get time.

from mixer.

Mappboy avatar Mappboy commented on September 16, 2024

I think this is similar issue to the fix in pull request #80

from mixer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.