Python, importing modules for testing
<p>I am having a very hard time trying to set up a simple test. </p>

<p>My project structure is as follows:</p>

<pre><code>project:
   models:
      __init__.py
      user.py
      constants.py
      test:
         test.py
</code></pre>

<p>I want to test <code>user.py</code> py running <code>test.py</code>. </p>

<p>user.py</p>

<pre><code>from sqlalchemy import Column, Integer, String, Text
from sqlalchemy.orm import relationship
from .models.constants import *
from .models import Base

class User(Base):
    __tablename__ = 'users'

    uid = Column(Integer, primary_key=True, autoincrement=True)
    name = Column(String, nullable=False)
    email = Column(String, nullable=False)
    picPath = Column(String, unique=True)
    description = Column(Text)

    def __repr__(self):
        return "&lt;User(uid=%s, name=%s)&gt;" %(self.uid, self.name)
</code></pre>

<p>test.py</p>

<pre><code>from ..user import User, Group

def _TestUser():
    TEST_DB_URI = "postgresql://project:password@localhost:5432/projectdbtest"
    SessionMaker = sessionmaker()
    engine = create_engine(TEST_DB_URI)
    SessionMaker.configure(bind=engine)

    session = SessionMaker()
    user = User("test subject", "testsubject@gmail.com", "~/testsubject.jpg", "I am a test subject")
    session.add(user)
    session.commit()
</code></pre>

<p>However, I am getting the following error when I run <code>python3 -m test.py</code>:</p>

<p>SystemError: Parent module '' not loaded, cannot perform relative import</p>

<p>I think I might have to add the modules package to the python path?</p>