Skip to content
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

Cannot find features or steps if the Django project is not the project root #51

Open
jscn opened this issue Aug 30, 2016 · 4 comments
Open

Comments

@jscn
Copy link

jscn commented Aug 30, 2016

If I have a project where the root directory is not the same as the Django project root directory, then aloe fails to find feature and step files in the Django project's apps.

For example, with the following project layout, aloe won't find awesome.feature because there is no __init__.py in the django_stuff directory:

$ tree project_root
project_root
└── django_stuff
    ├── db.sqlite3
    ├── manage.py
    ├── django_app
    │   ├── admin.py
    │   ├── apps.py
    │   ├── features
    │   │   └── awesome.feature
    │   ├── __init__.py
    │   ├── models.py
    │   ├── tests.py
    │   └── views.py
    └── django_stuff_project
        ├── __init__.py
        ├── settings.py
        ├── urls.py
        └── wsgi.py

I can resolve this by adding a __init__.py file to django_stuff, the Django project root, however this causes issues with Django itself: Django will consider the Django project root itself to be an "app", and will complain that models have been declared multiple times in different apps. See http://stackoverflow.com/questions/26591399/django-1-7-conflicting-models and https://code.djangoproject.com/ticket/22280 for examples of that problem.

@jscn
Copy link
Author

jscn commented Aug 30, 2016

Note that it's not a problem for unittest or nose, so aloe must be doing something different in requiring there to be __init__.py files all the way down (as seen at https://github.com/aloetesting/aloe/blob/master/aloe/fs.py#L83).

I was going to try writing my own custom implementation of the file discovery in a sub-class of aloe.fs.FeatureLoader, but there's no way to make django_aloe use a custom FeatureLoader at the moment (although you can override the gherkin_plugin() method of the Runner class, the aloe runner is hard coded at https://github.com/aloetesting/aloe_django/blob/master/aloe_django/runner.py#L41).

@jscn
Copy link
Author

jscn commented Aug 30, 2016

I suppose the FeatureLoader could look for either an __init__.py or a manage.py to determine where it should be importing from, but that wouldn't work for anyone who used a project layout without manage.py in the Django project root.

Could we add a Django setting which tells aloe what the Django project root is? Or perhaps an option for the harvest command that does the same? Or maybe it's possible to hook into Django itself somehow and use its app registry to determine where to look for feature and step files?

@koterpillar
Copy link
Member

koterpillar commented Aug 30, 2016

I'm not sure why is __init__.py required at the top directory. Will happily accept a patch removing that, so __init__.py is only required in subdirectories, this won't need any messing with manage.py.

(would also write it myself but that'll happen no earlier than in 3 weeks because holiday)

@jscn
Copy link
Author

jscn commented Aug 30, 2016

Fair enough, enjoy your holiday and I'll see what I can come up with in the meantime :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants