Results 1 to 3 of 3

Thread: Any people with Python Flask web framework experience out there?

  1. #1
    Join Date
    May 2020
    Location
    Earthrealm
    Beans
    15
    Distro
    Ubuntu 20.04 Focal Fossa

    Lightbulb Any people with Python Flask web framework experience out there?

    Any people with Python Flask web framework experience out there?
    Especially with using pytest for unit testing and functional testing. I have some complicated questions in my luggage to unfold.

  2. #2
    Join Date
    Oct 2017
    Location
    City of Waterfalls-Ph
    Beans
    Hidden!
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: Any people with Python Flask web framework experience out there?

    yes, mortalkorona. I'm not that expert on Flask but I have some python files here that will surely runs with Flask environment. which in fact, you can easily google it.
    corn ubuntuforums community.
    Open Source platform where the real world of human is here. Click here for Solve thread
    Rock n' Roll People.
    From: mike_08

  3. #3
    Join Date
    May 2020
    Location
    Earthrealm
    Beans
    15
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Any people with Python Flask web framework experience out there?

    Hi mlk, so I'm trying to learn and make pytest work for my Flask project by following this tutorial. I have managed to make PatKen's code work. But I wanted to refactor the Application Factory Function to use Config class object instead of using this tutorial's Config filename setup.

    Do you know if switching from Config filename to Config class object in the Application Factory Function is known for causing issues when pytesting Flask?


    Testing a Flask Application using pytest
    https://www.patricksoftwareblog.com/...-using-pytest/


    GitLab: flask_user_management_example
    https://gitlab.com/patkennedy79/flas...gement_example


    Instructions for bug fixing and setting up PatKen's example code:
    PHP Code:
    export FLASK_APP=main.py
    flask run

    # --- Error ---
    # sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: users

    #_______________________________________________________________________________

    flask db init

    # --- Error ---
    # directory = current_app.extensions['migrate'].directory
    # KeyError: 'migrate


    # --- Solution ---
    # /project/__init__.py

    from flask_migrate import Migrate # Was missing in example code.

        
    ..
        ..

    def initialize_extensions(app):
        
    migrate Migrate(appdb# Was missing in example code.

        
    ..
        ..

    #...............................................................................

    flask db migrate -"Users table."  
    flask db upgrade 

    #_______________________________________________________________________________

    /flask_user_management_examplepytest
    /flask_user_management_examplepytest tests

    # --- Error ---

    # ImportError while loading conftest '/flask_user_management_example/tests/conftest.py'.
    # tests/conftest.py:2: in <module>
    #   from project import create_app, db
    #   E   ModuleNotFoundError: No module named 'project'


    # --- Solution ---

    # Move 'conftest.py' file from here:
    /flask_user_management_example/tests/conftest.py

    # To here:
    /flask_user_management_example/conftest.py

    # Run the tests, all 10 tests should display PASSED:
    /flask_user_management_examplepytest -

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •