title: Flask can't import application from root directory to test
body: <p>I have the following folder structure:
  <a href="https://i.stack.imgur.com/ylqDT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ylqDT.png" alt="enter image description here" /></a></p>
  <p>In the application.py file I am using a factory method create_app():</p>
  <pre><code># application.py
  def create_app():
      flask_app = Flask(__name__)
      return flask_app
  
  
  app = create_app()
  
  # --- Import Routes ---
  from src.routes import *
  
  if __name__ == &quot;__main__&quot;:
      app.run()
  </code></pre>
  <p>In the test folder I have the following code</p>
  <pre><code># /tests/test.py
  from application import create_app
  
  
  def test_root_route():
      flask_app = create_app()
      with flask_app.test_client() as test_client:
          response = test_client.get('/')
          assert response.status_code == 200
          
  </code></pre>
  <p>Now I get the following error when running the test:
  from application import create_app
  ModuleNotFoundError: No module named 'application'</p>
  <p>Why can't I import the method from the application.py file?</p>
  <p>Unfortunately I can't change the folder structure as the application.py needs to be in root so it can be run by our server.</p>