DEV Community

crhodes
crhodes

Posted on

Question: Importing Error with Flask and Cucumber

I am working on a project with the following tree structure:

Project
  - Source
  - Web
       - test
         - features
            testing.features
         - steps
            testing.py
       - app
         - __init__.py
         - blueprints
            communication_bp.py
Enter fullscreen mode Exit fullscreen mode

I am working on a cucumber test code using the behave module and the folder I am working on is the test folder, which include features and steps.

What I am trying to do is to import some methods found in communication_bp.py from the app folder into the cucumber test file testing.py in python.

So Line 3 is what I am trying to achieve.

testing.py:

from behave_restful import *
import requests
from blueprints.communication_bp import client_comm
Enter fullscreen mode Exit fullscreen mode

but I keep getting this error.

  File "../steps/testing.py", line 3, in <module>
    from blueprints.communication_bp import client_comm
ModuleNotFoundError: No module named 'blueprints'
Enter fullscreen mode Exit fullscreen mode

Based on what I have read, the app folder is supposed to have __init__.py, which it does.

I will include what both this file and communication_bp.py file here as well.

init.py

from flask import Flask
from flask_cors import CORS
from flask_jwt_extended import JWTManager
from flask_socketio import SocketIO

# Create the Flask application
rest = Flask(__name__)
...
...
from app.blueprints.communication_bp import communication_bp
...
...

rest.register_blueprint(communication_bp, url_prefix = Config.API_PREFIX)
...
...
Enter fullscreen mode Exit fullscreen mode

communication_bp.py

import sys
import json
from flask import Blueprint, request
...
...
Enter fullscreen mode Exit fullscreen mode

So what exactly does this program wants? What am I missing here?

Top comments (0)