Please note that I’m referring to Python 2.x here, not Python 3.x.

I have a simple Python project laid out like this:


I’d like to use to test (unsurprisingly). But how do I import into my test? If you’re a NodeJS fanboy like myself, you might think you can do something like this:

import '../src/main'

Right? WRONG. Take your sensible, Bash style imports back to Nodeland, you glorified jQuery developer.

In Python, you need to do two things. First, create a blank file inside tests/. This makes it into a package or something. Then, you can use this syntax to import the file:

from src import main

And then you’re good.