Git Product home page Git Product logo

flask_demo's Introduction

Flask_Demo

Environment

  • Python 3.7

  • Flask 1.1.1

Running blog_demo

  • Initialize Database:
(venv) jzongnan (master *+) Flask_Demo
$ export FLASK_APP=main/main.py
(venv) jzongnan (master *+) Flask_Demo
$ export FLASK_ENV=development
(venv) jzongnan (master *+) Flask_Demo
$ flask init-db
Initialized the database.
  • Run blog_demo:
(venv) jzongnan (master *+) Flask_Demo
$ flask run
 * Serving Flask app "main/main.py" (lazy loading)
 * Environment: development
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 287-589-682

Running blog_demo tests

  • Install pytest and coverage first pip install pytest coverage
  • set environment variable PYTHONPATH as your project directory, then launch pytest
(venv) jzongnan (master *+) Flask_Demo
$ export PYTHONPATH=/Users/jzongnan/PycharmProjects/Flask_Demo
(venv) jzongnan (master) Flask_Demo
$ pytest
====================================================================== test session starts =======================================================================
platform darwin -- Python 3.8.0, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: /Users/jzongnan/PycharmProjects/Flask_Demo, inifile: setup.cfg, testpaths: tests
collected 24 items                                                                                                                                               

tests/test_auth.py ........                                                                                                                                [ 33%]
tests/test_blog.py ............                                                                                                                            [ 83%]
tests/test_db.py ..                                                                                                                                        [ 91%]
tests/test_factory.py ..                                                                                                                                   [100%]

======================================================================= 24 passed in 2.23s =======================================================================
  • Show test coverage
(venv) jzongnan (master) Flask_Demo
$ coverage run -m pytest
====================================================================== test session starts =======================================================================
platform darwin -- Python 3.8.0, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: /Users/jzongnan/PycharmProjects/Flask_Demo, inifile: setup.cfg, testpaths: tests
collected 24 items                                                                                                                                               

tests/test_auth.py ........                                                                                                                                [ 33%]
tests/test_blog.py ............                                                                                                                            [ 83%]
tests/test_db.py ..                                                                                                                                        [ 91%]
tests/test_factory.py ..                                                                                                                                   [100%]

======================================================================= 24 passed in 2.92s =======================================================================
(venv) jzongnan (master) Flask_Demo
$ coverage report
Name                 Stmts   Miss Branch BrPart  Cover
------------------------------------------------------
basic/basic_app.py      34     14      2      0    56%
blog_demo/auth.py       59      0     22      0   100%
blog_demo/blog.py       58      0     16      0   100%
blog_demo/db.py         25      0      4      0   100%
main/__init__.py         0      0      0      0   100%
main/main.py            27      0      2      0   100%
------------------------------------------------------
TOTAL                  203     14     46      0    94%
  • Generate test coverage details in html, then open htmlcov/index.html
(venv) jzongnan (master) Flask_Demo
$ coverage html
(venv) jzongnan (master) Flask_Demo
$ 

Screenshot

flask_demo's People

Contributors

jinzongna avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.