nestorsalceda/mamba — pull request #31 by jaimegildesagredo (2014-02-03 12:02:49+00:00)
Title: Improved import logic to allow relative imports within specs

With large spec suites it's common to extract some helper functions to a `helpers` module and then import the needed functions into you spec module.

You could do it like this:

```python
from spec.helpers import my_helper_function
```

But this won't work unless you manually specify the `PYTHONPATH` to the parent directory before running mamba. A way to solve this is by using relative imports:

```python
from .helpers import my_helper_function
```

But with the current implementation it doesn't work, even specifying a `PYTHONPATH`.

So I decided to improve the import logic to support relative imports within specs. Now when importing a module from a source file, the correct `PYTHONPATH` is set and the module is imported taking care of its parent packages with [importlib](http://docs.python.org/2.7/library/importlib.html), so relative imports will work.