Skip to content

Commit 3c7625e

Browse files
committed
update development resources
fix tox to test examples again add detox tox env for faster testing clean up makefile, add tox target add extra group for installing dev requirements clean up contributing doc, build with docs expand issue template add pull request template
1 parent a37f675 commit 3c7625e

8 files changed

+188
-116
lines changed

.github/ISSUE_TEMPLATE.rst

+33-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,33 @@
1-
The issue tracker is a tool to address bugs.
2-
Please use the #pocoo IRC channel on freenode or Stack Overflow for questions.
1+
**This issue tracker is a tool to address bugs in Flask itself.
2+
Please use the #pocoo IRC channel on freenode or Stack Overflow for general
3+
questions about using Jinja or issues not related to Jinja.**
4+
5+
If you'd like to report a bug in Flask, fill out the template below. Provide
6+
any any extra information that may be useful / related to your problem.
7+
Ideally, create an [MCVE](http://stackoverflow.com/help/mcve), which helps us
8+
understand the problem and helps check that it is not caused by something in
9+
your code.
10+
11+
---
12+
13+
### Expected Behavior
14+
15+
Tell us what should happen.
16+
17+
```python
18+
Paste a minimal example that causes the problem.
19+
```
20+
21+
### Actual Behavior
22+
23+
Tell us what happens instead.
24+
25+
```pytb
26+
Paste the full traceback if there was an exception.
27+
```
28+
29+
### Environment
30+
31+
* Python version:
32+
* Flask version:
33+
* Werkzeug version:

.github/PULL_REQUEST_TEMPLATE.rst

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Describe what this patch does to fix the issue.
2+
3+
Link to any relevant issues or pull requests.
4+
5+
<!--
6+
Commit checklist:
7+
8+
* add tests that fail without the patch
9+
* ensure all tests pass with ``pytest``
10+
* add documentation to the relevant docstrings or pages
11+
* add ``versionadded`` or ``versionchanged`` directives to relevant docstrings
12+
* add a changelog entry if this patch changes code
13+
14+
Tests, coverage, and docs will be run automatically when you submit the pull
15+
request, but running them yourself can save time.
16+
-->

CONTRIBUTING.rst

+93-92
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,75 @@
1-
==========================
21
How to contribute to Flask
32
==========================
43

5-
Thanks for considering contributing to Flask.
4+
Thank you for considering contributing to Flask!
65

76
Support questions
8-
=================
7+
-----------------
8+
9+
Please, don't use the issue tracker for this. Use one of the following
10+
resources for questions about your own code:
11+
12+
* The IRC channel ``#pocoo`` on FreeNode.
13+
* The IRC channel ``#python`` on FreeNode for more general questions.
14+
* The mailing list [email protected] for long term discussion or larger issues.
15+
* Ask on `Stack Overflow`_. Search with Google first using:
16+
``site:stackoverflow.com flask {search term, exception message, etc.}``
917

10-
Please, don't use the issue tracker for this. Check whether the ``#pocoo`` IRC
11-
channel on Freenode can help with your issue. If your problem is not strictly
12-
Werkzeug or Flask specific, ``#python`` is generally more active.
13-
`Stack Overflow <https://stackoverflow.com/>`_ is also worth considering.
18+
.. _Stack Overflow: https://stackoverflow.com/questions/tagged/flask?sort=linked
1419

1520
Reporting issues
16-
================
21+
----------------
1722

18-
- Under which versions of Python does this happen? This is even more important
19-
if your issue is encoding related.
23+
- Describe what you expected to happen.
24+
- If possible, include a `minimal, complete, and verifiable example`_ to help
25+
us identify the issue. This also helps check that the issue is not with your
26+
own code.
27+
- Describe what actually happened. Include the full traceback if there was an
28+
exception.
29+
- List your Python, Flask, and Werkzeug versions. If possible, check if this
30+
issue is already fixed in the repository.
2031

21-
- Under which versions of Werkzeug does this happen? Check if this issue is
22-
fixed in the repository.
32+
.. _minimal, complete, and verifiable example: https://stackoverflow.com/help/mcve
2333

2434
Submitting patches
25-
==================
35+
------------------
2636

2737
- Include tests if your patch is supposed to solve a bug, and explain
2838
clearly under which circumstances the bug happens. Make sure the test fails
2939
without your patch.
30-
31-
- Try to follow `PEP8 <https://www.python.org/dev/peps/pep-0008/>`_, but you
32-
may ignore the line-length-limit if following it would make the code uglier.
40+
- Try to follow `PEP8`_, but you may ignore the line length limit if following
41+
it would make the code uglier.
3342

3443
First time setup
35-
----------------
44+
~~~~~~~~~~~~~~~~
3645

3746
- Download and install the `latest version of git`_.
38-
- Configure git with your `username`_ and `email`_.
47+
- Configure git with your `username`_ and `email`_::
48+
49+
git config --global user.name 'your name'
50+
git config --global user.email 'your email'
51+
3952
- Make sure you have a `GitHub account`_.
4053
- Fork Flask to your GitHub account by clicking the `Fork`_ button.
41-
- `Clone`_ your GitHub fork locally.
42-
- Add the main repository as a remote to update later.
43-
``git remote add pallets https://github.com/pallets/flask``
54+
- `Clone`_ your GitHub fork locally::
55+
56+
git clone https://github.com/{username}/flask
57+
cd flask
58+
59+
- Add the main repository as a remote to update later::
60+
61+
git remote add pallets https://github.com/pallets/flask
62+
git fetch pallets
63+
64+
- Create a virtualenv::
65+
66+
python3 -m venv env
67+
. env/bin/activate
68+
# or "env\Scripts\activate" on Windows
69+
70+
- Install Flask in editable mode with development dependencies::
71+
72+
pip install -e ".[dev]"
4473

4574
.. _GitHub account: https://github.com/join
4675
.. _latest version of git: https://git-scm.com/downloads
@@ -50,7 +79,7 @@ First time setup
5079
.. _Clone: https://help.github.com/articles/fork-a-repo/#step-2-create-a-local-clone-of-your-fork
5180

5281
Start coding
53-
------------
82+
~~~~~~~~~~~~
5483

5584
- Create a branch to identify the issue you would like to work on (e.g.
5685
``2287-dry-test-suite``)
@@ -68,98 +97,70 @@ Start coding
6897

6998
.. _contributing-testsuite:
7099

71-
Running the testsuite
72-
---------------------
100+
Running the tests
101+
~~~~~~~~~~~~~~~~~
73102

74-
You probably want to set up a `virtualenv
75-
<https://virtualenv.readthedocs.io/en/latest/index.html>`_.
103+
Run the basic test suite with::
76104

77-
The minimal requirement for running the testsuite is ``pytest``. You can
78-
install it with::
105+
pytest
79106

80-
pip install pytest
107+
This only runs the tests for the current environment. Whether this is relevant
108+
depends on which part of Flask you're working on. Travis-CI will run the full
109+
suite when you submit your pull request.
81110

82-
Clone this repository::
111+
The full test suite takes a long time to run because it tests multiple
112+
combinations of Python and dependencies. You need to have Python 2.6, 2.7, 3.3,
113+
3.4, 3.5 3.6, and PyPy 2.7 installed to run all of the environments. Then run::
83114

84-
git clone https://github.com/pallets/flask.git
85-
86-
Install Flask as an editable package using the current source::
87-
88-
cd flask
89-
pip install --editable .
90-
91-
Running the testsuite
92-
---------------------
93-
94-
The minimal requirement for running the testsuite is ``pytest``. You can
95-
install it with::
96-
97-
pip install pytest
98-
99-
Then you can run the testsuite with::
100-
101-
pytest tests/
102-
103-
**Shortcut**: ``make test`` will ensure ``pytest`` is installed, and run it.
104-
105-
With only pytest installed, a large part of the testsuite will get skipped
106-
though. Whether this is relevant depends on which part of Flask you're working
107-
on. Travis is set up to run the full testsuite when you submit your pull
108-
request anyways.
109-
110-
If you really want to test everything, you will have to install ``tox`` instead
111-
of ``pytest``. You can install it with::
112-
113-
pip install tox
114-
115-
The ``tox`` command will then run all tests against multiple combinations
116-
Python versions and dependency versions.
117-
118-
**Shortcut**: ``make tox-test`` will ensure ``tox`` is installed, and run it.
115+
tox
119116

120117
Running test coverage
121-
---------------------
122-
Generating a report of lines that do not have unit test coverage can indicate where
123-
to start contributing. ``pytest`` integrates with ``coverage.py``, using the ``pytest-cov``
124-
plugin. This assumes you have already run the testsuite (see previous section)::
118+
~~~~~~~~~~~~~~~~~~~~~
125119

126-
pip install pytest-cov
120+
Generating a report of lines that do not have test coverage can indicate
121+
where to start contributing. Run ``pytest`` using ``coverage`` and generate a
122+
report on the terminal and as an interactive HTML document::
127123

128-
After this has been installed, you can output a report to the command line using this command::
124+
coverage run -m pytest
125+
coverage report
126+
coverage html
127+
# then open htmlcov/index.html
129128

130-
pytest --cov=flask tests/
129+
Read more about `coverage <https://coverage.readthedocs.io>`_.
131130

132-
Generate a HTML report can be done using this command::
131+
Running the full test suite with ``tox`` will combine the coverage reports
132+
from all runs.
133133

134-
pytest --cov-report html --cov=flask tests/
134+
``make`` targets
135+
~~~~~~~~~~~~~~~~
135136

136-
Full docs on ``coverage.py`` are here: https://coverage.readthedocs.io
137+
Flask provides a ``Makefile`` with various shortcuts. They will ensure that
138+
all dependencies are installed.
137139

138-
**Shortcut**: ``make cov`` will ensure ``pytest-cov`` is installed, run it, display the results, *and* save the HTML report.
140+
- ``make test`` runs the basic test suite with ``pytest``
141+
- ``make cov`` runs the basic test suite with ``coverage``
142+
- ``make test-all`` runs the full test suite with ``tox``
143+
- ``make docs`` builds the HTML documentation
139144

145+
Caution: zero-padded file modes
146+
-------------------------------
140147

141-
Caution
142-
=======
143-
pushing
144-
-------
145-
This repository contains several zero-padded file modes that may cause issues when pushing this repository to git hosts other than github. Fixing this is destructive to the commit history, so we suggest ignoring these warnings. If it fails to push and you're using a self-hosted git service like Gitlab, you can turn off repository checks in the admin panel.
148+
This repository contains several zero-padded file modes that may cause issues
149+
when pushing this repository to git hosts other than GitHub. Fixing this is
150+
destructive to the commit history, so we suggest ignoring these warnings. If it
151+
fails to push and you're using a self-hosted git service like GitLab, you can
152+
turn off repository checks in the admin panel.
146153

147-
148-
cloning
149-
-------
150-
The zero-padded file modes files above can cause issues while cloning, too. If you have
151-
152-
::
154+
These files can also cause issues while cloning. If you have ::
153155

154156
[fetch]
155157
fsckobjects = true
156158

157-
or
158-
159-
::
159+
or ::
160160

161161
[receive]
162162
fsckObjects = true
163163

164-
165-
set in your git configuration file, cloning this repository will fail. The only solution is to set both of the above settings to false while cloning, and then setting them back to true after the cloning is finished.
164+
set in your git configuration file, cloning this repository will fail. The only
165+
solution is to set both of the above settings to false while cloning, and then
166+
setting them back to true after the cloning is finished.

Makefile

+22-14
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
1-
.PHONY: clean-pyc ext-test test tox-test test-with-mem upload-docs docs audit
1+
.PHONY: all install-dev test coverage cov test-all tox docs audit release clean-pyc upload-docs ebook
22

3-
all: clean-pyc test
3+
all: test
44

5-
test:
6-
pip install -r test-requirements.txt
7-
tox -e py-release
5+
install-dev:
6+
pip install -q -e .[dev]
87

9-
cov:
10-
pip install -r test-requirements.txt -q
11-
FLASK_DEBUG= py.test --cov-report term --cov-report html --cov=flask --cov=examples tests examples
8+
test: clean-pyc install-dev
9+
pytest
10+
11+
coverage: clean-pyc install-dev
12+
pip install -q -e .[test]
13+
coverage run -m pytest
14+
coverage report
15+
coverage html
16+
17+
cov: coverage
18+
19+
test-all: install-dev
20+
tox
21+
22+
tox: test-all
23+
24+
docs: clean-pyc install-dev
25+
$(MAKE) -C docs html
1226

1327
audit:
1428
python setup.py audit
1529

1630
release:
1731
python scripts/make-release.py
1832

19-
ext-test:
20-
python tests/flaskext_test.py --browse
21-
2233
clean-pyc:
2334
find . -name '*.pyc' -exec rm -f {} +
2435
find . -name '*.pyo' -exec rm -f {} +
@@ -40,6 +51,3 @@ ebook:
4051
@echo 'Requires X-forwarding for Qt features used in conversion (ssh -X).'
4152
@echo 'Do not mind "Invalid value for ..." CSS errors if .mobi renders.'
4253
ssh -X pocoo.org ebook-convert /var/www/flask.pocoo.org/docs/flask-docs.epub /var/www/flask.pocoo.org/docs/flask-docs.mobi --cover http://flask.pocoo.org/docs/_images/logo-full.png --authors 'Armin Ronacher'
43-
44-
docs:
45-
$(MAKE) -C docs html

docs/contents.rst.inc

+1
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ Design notes, legal information and changelog are here for the interested.
5959
upgrading
6060
changelog
6161
license
62+
contributing

docs/contributing.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. include:: ../CONTRIBUTING.rst

setup.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,12 @@ def hello():
4848
import ast
4949
from setuptools import setup
5050

51-
5251
_version_re = re.compile(r'__version__\s+=\s+(.*)')
5352

5453
with open('flask/__init__.py', 'rb') as f:
5554
version = str(ast.literal_eval(_version_re.search(
5655
f.read().decode('utf-8')).group(1)))
5756

58-
5957
setup(
6058
name='Flask',
6159
version=version,
@@ -76,6 +74,17 @@ def hello():
7674
'itsdangerous>=0.21',
7775
'click>=4.0',
7876
],
77+
extras_require={
78+
'dev': [
79+
'blinker',
80+
'greenlet',
81+
'pytest>=3',
82+
'coverage',
83+
'tox',
84+
'sphinx',
85+
'sphinxcontrib-log-cabinet'
86+
],
87+
},
7988
classifiers=[
8089
'Development Status :: 4 - Beta',
8190
'Environment :: Web Environment',

0 commit comments

Comments
 (0)