gabrielfalcao/lettuce

RuntimeError - Conflicting models

robinelvin opened this issue · 0 comments

I'm getting the following error when running harvest on my Django 1.7 app:

RuntimeError: Conflicting 'organisation' models in application 'portal': <class 'portal.models.Organisation'> and <class 'models.Organisation'>.

This seems to be the issue described in https://code.djangoproject.com/ticket/22280 but the Django test runner does not give this issue so I think this must just be due to Lettuce

Any ideas?

EDIT:

This quick hack fixed it for me:

fs.py

def find_and_load_step_definitions(self):
    # find steps, possibly up several directories
    base_dir = self.base_dir
    while base_dir != '/':
        files = FileSystem.locate(base_dir, '*.py')
        if files:
            break
        base_dir = FileSystem.join(base_dir, '..')


    for filename in files:
        root = FileSystem.dirname(filename)
        sys.path.insert(0, root)
        to_load = FileSystem.filename(filename, with_extension=False)
        app = root.split(os.sep)[-1]
        to_load = "%s.%s" % (app, to_load)
        module = None
        try:
            module = __import__(to_load)
        except ValueError, e:
            import traceback
            err_msg = traceback.format_exc(e)
            if 'empty module name' in err_msg.lower():
                continue
            else:
                e.args = ('{0} when importing {1}'
                          .format(e, filename)),
                raise e
        except ImportError:
            pass

        if module:
            reload(module) # always take fresh meat :)
        sys.path.remove(root)