title: ModuleNotFoundError: No module named 'app' when trying to create a Test using Pytest and Flask on Windows virtual enviroment
body: <p>I'm trying to create a test for my Flask app using the <a href="https://flask.palletsprojects.com/en/1.1.x/testing/" rel="nofollow noreferrer">Flask Test tutorial</a> but when I run the tests using pytest it throws the following error:</p>
  
  <pre><code>Hint: make sure your test modules/packages have valid Python names.
  Traceback:
  test\test_flask.py:6: in &lt;module&gt;
      from app import app
  E   ModuleNotFoundError: No module named 'app'
  </code></pre>
  
  <p>I'm using Windows 10, virtual enviroment for the flask app and Python 3.8. How can I solve this?</p>
  
  <p>My project structure is:</p>
  
  <p><a href="https://i.stack.imgur.com/MuxHl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MuxHl.png" alt="Project Tree from VsCode"></a></p>
  
  <p>test_flask.py:</p>
  
  <pre><code>import os
  import tempfile
  
  import pytest
  
  from app import app
  
  @pytest.fixture
  def client():
      db_fd, app.config['DATABASE'] = tempfile.mkstemp()
      app.config['TESTING'] = True
  
      with app.app.test_client() as client:
          with app.app.context():
              app.init_db()
          yield client
  
      os.close(db_fd)
      os.unlink(app.app.config['DATABASE'])
  </code></pre>
  
  <p>and <strong>init</strong>.py:</p>
  
  <pre><code>from flask import Flask, request, jsonify
  from config import Config
  from flask_sqlalchemy import SQLAlchemy
  from flask_migrate import Migrate
  from werkzeug.security import generate_password_hash, check_password_hash
  from flask_jwt_extended import (
      JWTManager, jwt_required, create_access_token,
      get_jwt_identity
  )
  from flask_cors import CORS
  
  app = Flask(__name__)
  app.config.from_object(Config)
  db = SQLAlchemy(app)
  migrate = Migrate(app, db)
  jwt = JWTManager(app)
  CORS(app)
  app.config['CORS_HEADERS'] = 'Content-Type'
  
  
  from app import routes, models
  </code></pre>
  
  <p>mymanhualist.py:</p>
  
  <pre><code>from app import app
  </code></pre>