* Converts example/flaskr to have a setup.py Makes the flaskr app easier to run, ex. workflow: - pip install --editable . - export FLASK_APP=flaskr.flaskr - flask initdb - flask run Testing is also easier now: - python setup.py test * Fixed an import error in flaskr/tests - the statement `import flaskr` caused errors in python3 - `from . import flaskr` fixes the issue in 2.7.11 and 3.5.1 * Better project structure and updates the docs - Re-factors *flaskr*'s project structure a bit - Updates docs to make sense with the new structure - Adds a new step about installing Flask apps with setuptools - Switches first-person style writing to second-person (reads better IMO) - Adds segments in *testing.rst* for running tests with setuptools * Remove __init__.py from tests - py.test recommends not using __init__.py * Fix testing import errors
This commit is contained in:
parent
1ffd07ff5a
commit
17d4cb3828
26 changed files with 323 additions and 127 deletions
1
examples/flaskr/.gitignore
vendored
1
examples/flaskr/.gitignore
vendored
|
|
@ -1 +1,2 @@
|
|||
flaskr.db
|
||||
.eggs/
|
||||
|
|
|
|||
3
examples/flaskr/MANIFEST.in
Normal file
3
examples/flaskr/MANIFEST.in
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
graft flaskr/templates
|
||||
graft flaskr/static
|
||||
include flaskr/schema.sql
|
||||
|
|
@ -13,15 +13,19 @@
|
|||
export an FLASKR_SETTINGS environment variable
|
||||
pointing to a configuration file.
|
||||
|
||||
2. Instruct flask to use the right application
|
||||
2. install the app from the root of the project directory
|
||||
|
||||
export FLASK_APP=flaskr
|
||||
pip install --editable .
|
||||
|
||||
3. initialize the database with this command:
|
||||
3. Instruct flask to use the right application
|
||||
|
||||
export FLASK_APP=flaskr.flaskr
|
||||
|
||||
4. initialize the database with this command:
|
||||
|
||||
flask initdb
|
||||
|
||||
4. now you can run flaskr:
|
||||
5. now you can run flaskr:
|
||||
|
||||
flask run
|
||||
|
||||
|
|
@ -30,5 +34,5 @@
|
|||
|
||||
~ Is it tested?
|
||||
|
||||
You betcha. Run the `test_flaskr.py` file to see
|
||||
You betcha. Run `python setup.py test` to see
|
||||
the tests pass.
|
||||
|
|
|
|||
0
examples/flaskr/flaskr/__init__.py
Normal file
0
examples/flaskr/flaskr/__init__.py
Normal file
2
examples/flaskr/setup.cfg
Normal file
2
examples/flaskr/setup.cfg
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[aliases]
|
||||
test=pytest
|
||||
16
examples/flaskr/setup.py
Normal file
16
examples/flaskr/setup.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='flaskr',
|
||||
packages=['flaskr'],
|
||||
include_package_data=True,
|
||||
install_requires=[
|
||||
'flask',
|
||||
],
|
||||
setup_requires=[
|
||||
'pytest-runner',
|
||||
],
|
||||
tests_require=[
|
||||
'pytest',
|
||||
],
|
||||
)
|
||||
6
examples/flaskr/tests/context.py
Normal file
6
examples/flaskr/tests/context.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import sys, os
|
||||
|
||||
basedir = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.insert(0, basedir + '/../')
|
||||
|
||||
from flaskr import flaskr
|
||||
|
|
@ -10,11 +10,10 @@
|
|||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
import os
|
||||
import flaskr
|
||||
import tempfile
|
||||
|
||||
from context import flaskr
|
||||
|
||||
@pytest.fixture
|
||||
def client(request):
|
||||
Loading…
Add table
Add a link
Reference in a new issue