aloe_django
aloe_django copied to clipboard
Cannot find features or steps if the Django project is not the project root
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.
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).
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?
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)
Fair enough, enjoy your holiday and I'll see what I can come up with in the meantime :)