Skip to content
Myr

Merge pull request #2343 from davidism/tests

Before adoption: this commit came in with the history the project adopted, so no landing records it.

update development resources

authored by David Lord · committed by GitHub · parents a37f675, 3c7625e · Browse files · 8 files+188 added−116 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+188 added−116 removed

  • other:+188 added−116 removed

8 files+188 added−116 removed

modified:.github/ISSUE_TEMPLATE.rst+33 added-2 removed
1The issue tracker is a tool to address bugs.2Please 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.2Please use the #pocoo IRC channel on freenode or Stack Overflow for general3questions about using Jinja or issues not related to Jinja.**45If you'd like to report a bug in Flask, fill out the template below. Provide6any any extra information that may be useful / related to your problem.7Ideally, create an [MCVE](http://stackoverflow.com/help/mcve), which helps us8understand the problem and helps check that it is not caused by something in9your code.1011---1213### Expected Behavior1415Tell us what should happen.1617```python18Paste a minimal example that causes the problem.19```2021### Actual Behavior2223Tell us what happens instead.2425```pytb26Paste the full traceback if there was an exception.27```2829### Environment3031* Python version:32* Flask version:33* Werkzeug version:
added:.github/PULL_REQUEST_TEMPLATE.rst+16 added
1Describe what this patch does to fix the issue.23Link to any relevant issues or pull requests.45<!--6Commit checklist:78* add tests that fail without the patch9* ensure all tests pass with ``pytest``10* add documentation to the relevant docstrings or pages11* add ``versionadded`` or ``versionchanged`` directives to relevant docstrings12* add a changelog entry if this patch changes code1314Tests, coverage, and docs will be run automatically when you submit the pull15request, but running them yourself can save time.16-->
modified:docs/contents.rst.inc+1 added
57 unmodified lines
58 python359 upgrading60 changelog61 license62 contributing
added:docs/contributing.rst+1 added
1.. include:: ../CONTRIBUTING.rst
modified:CONTRIBUTING.rst+93 added-92 removed
1==========================1How to contribute to Flask2==========================35Thanks for considering contributing to Flask.4Thank you for considering contributing to Flask!56Support questions8=================7-----------------810Please, don't use the issue tracker for this. Check whether the ``#pocoo`` IRC11channel on Freenode can help with your issue. If your problem is not strictly12Werkzeug or Flask specific, ``#python`` is generally more active.13`Stack Overflow <https://stackoverflow.com/>`_ is also worth considering.9Please, don't use the issue tracker for this. Use one of the following10resources for questions about your own code:1112* The IRC channel ``#pocoo`` on FreeNode.13* The IRC channel ``#python`` on FreeNode for more general questions.14* The mailing list flask@python.org 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.}``1718.. _Stack Overflow: https://stackoverflow.com/questions/tagged/flask?sort=linked1920Reporting issues16================21----------------2218- Under which versions of Python does this happen? This is even more important19 if your issue is encoding related.23- Describe what you expected to happen.24- If possible, include a `minimal, complete, and verifiable example`_ to help25 us identify the issue. This also helps check that the issue is not with your26 own code.27- Describe what actually happened. Include the full traceback if there was an28 exception.29- List your Python, Flask, and Werkzeug versions. If possible, check if this30 issue is already fixed in the repository.3121- Under which versions of Werkzeug does this happen? Check if this issue is22 fixed in the repository.32.. _minimal, complete, and verifiable example: https://stackoverflow.com/help/mcve3334Submitting patches25==================35------------------3637- Include tests if your patch is supposed to solve a bug, and explain38 clearly under which circumstances the bug happens. Make sure the test fails39 without your patch.40- Try to follow `PEP8`_, but you may ignore the line length limit if following41 it would make the code uglier.4231- Try to follow `PEP8 <https://www.python.org/dev/peps/pep-0008/>`_, but you32 may ignore the line-length-limit if following it would make the code uglier.3343First time setup35----------------44~~~~~~~~~~~~~~~~4546- Download and install the `latest version of git`_.38- Configure git with your `username`_ and `email`_.47- Configure git with your `username`_ and `email`_::4849 git config --global user.name 'your name'50 git config --global user.email 'your email'5152- Make sure you have a `GitHub account`_.53- 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::5556 git clone https://github.com/{username}/flask57 cd flask5859- Add the main repository as a remote to update later::6061 git remote add pallets https://github.com/pallets/flask62 git fetch pallets6364- Create a virtualenv::6566 python3 -m venv env67 . env/bin/activate68 # or "env\Scripts\activate" on Windows6970- Install Flask in editable mode with development dependencies::7172 pip install -e ".[dev]"7374.. _GitHub account: https://github.com/join75.. _latest version of git: https://git-scm.com/downloads76.. _username: https://help.github.com/articles/setting-your-username-in-git/77.. _email: https://help.github.com/articles/setting-your-email-in-git/78.. _Fork: https://github.com/pallets/flask/pull/2305#fork-destination-box79.. _Clone: https://help.github.com/articles/fork-a-repo/#step-2-create-a-local-clone-of-your-fork8081Start coding53------------82~~~~~~~~~~~~8384- Create a branch to identify the issue you would like to work on (e.g.85 ``2287-dry-test-suite``)86- Using your favorite editor, make your changes, `committing as you go`_.
9 unmodified lines
96.. _create a pull request: https://help.github.com/articles/creating-a-pull-request/9798.. _contributing-testsuite:9971Running the testsuite72---------------------100Running the tests101~~~~~~~~~~~~~~~~~10274You probably want to set up a `virtualenv75<https://virtualenv.readthedocs.io/en/latest/index.html>`_.103Run the basic test suite with::10477The minimal requirement for running the testsuite is ``pytest``. You can78install it with::105 pytest10680 pip install pytest107This only runs the tests for the current environment. Whether this is relevant108depends on which part of Flask you're working on. Travis-CI will run the full109suite when you submit your pull request.11082Clone this repository::111The full test suite takes a long time to run because it tests multiple112combinations of Python and dependencies. You need to have Python 2.6, 2.7, 3.3,1133.4, 3.5 3.6, and PyPy 2.7 installed to run all of the environments. Then run::11484 git clone https://github.com/pallets/flask.git115 tox11686Install Flask as an editable package using the current source::8788 cd flask89 pip install --editable .9091Running the testsuite92---------------------9394The minimal requirement for running the testsuite is ``pytest``. You can95install it with::9697 pip install pytest9899Then you can run the testsuite with::100101 pytest tests/102103**Shortcut**: ``make test`` will ensure ``pytest`` is installed, and run it.104105With only pytest installed, a large part of the testsuite will get skipped106though. Whether this is relevant depends on which part of Flask you're working107on. Travis is set up to run the full testsuite when you submit your pull108request anyways.109110If you really want to test everything, you will have to install ``tox`` instead111of ``pytest``. You can install it with::112113 pip install tox114115The ``tox`` command will then run all tests against multiple combinations116Python versions and dependency versions.117118**Shortcut**: ``make tox-test`` will ensure ``tox`` is installed, and run it.119117Running test coverage121---------------------122Generating a report of lines that do not have unit test coverage can indicate where123to start contributing. ``pytest`` integrates with ``coverage.py``, using the ``pytest-cov``124plugin. This assumes you have already run the testsuite (see previous section)::118~~~~~~~~~~~~~~~~~~~~~119126 pip install pytest-cov120Generating a report of lines that do not have test coverage can indicate121where to start contributing. Run ``pytest`` using ``coverage`` and generate a122report on the terminal and as an interactive HTML document::123128After this has been installed, you can output a report to the command line using this command::124 coverage run -m pytest125 coverage report126 coverage html127 # then open htmlcov/index.html128130 pytest --cov=flask tests/129Read more about `coverage <https://coverage.readthedocs.io>`_.130132Generate a HTML report can be done using this command::131Running the full test suite with ``tox`` will combine the coverage reports132from all runs.133134 pytest --cov-report html --cov=flask tests/134``make`` targets135~~~~~~~~~~~~~~~~136136Full docs on ``coverage.py`` are here: https://coverage.readthedocs.io137Flask provides a ``Makefile`` with various shortcuts. They will ensure that138all dependencies are installed.139138**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 documentation144145Caution: zero-padded file modes146-------------------------------147141Caution142=======143pushing144-------145This 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.148This repository contains several zero-padded file modes that may cause issues149when pushing this repository to git hosts other than GitHub. Fixing this is150destructive to the commit history, so we suggest ignoring these warnings. If it151fails to push and you're using a self-hosted git service like GitLab, you can152turn off repository checks in the admin panel.153154These files can also cause issues while cloning. If you have ::155148cloning149-------150The zero-padded file modes files above can cause issues while cloning, too. If you have151152::153156 [fetch]157 fsckobjects = true158157or159or ::160159::160161 [receive]162 fsckObjects = true163164165set 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.164set in your git configuration file, cloning this repository will fail. The only165solution is to set both of the above settings to false while cloning, and then166setting them back to true after the cloning is finished.
modified:Makefile+22 added-14 removed
1.PHONY: clean-pyc ext-test test tox-test test-with-mem upload-docs docs audit1.PHONY: all install-dev test coverage cov test-all tox docs audit release clean-pyc upload-docs ebook23all: clean-pyc test3all: test45test:6 pip install -r test-requirements.txt7 tox -e py-release5install-dev:6 pip install -q -e .[dev]79cov:10 pip install -r test-requirements.txt -q11 FLASK_DEBUG= py.test --cov-report term --cov-report html --cov=flask --cov=examples tests examples8test: clean-pyc install-dev9 pytest1011coverage: clean-pyc install-dev12 pip install -q -e .[test]13 coverage run -m pytest14 coverage report15 coverage html1617cov: coverage1819test-all: install-dev20 tox2122tox: test-all2324docs: clean-pyc install-dev25 $(MAKE) -C docs html2627audit:28 python setup.py audit2930release:31 python scripts/make-release.py3219ext-test:20 python tests/flaskext_test.py --browse2133clean-pyc:34 find . -name '*.pyc' -exec rm -f {} +35 find . -name '*.pyo' -exec rm -f {} +36 find . -name '*~' -exec rm -f {} +
13 unmodified lines
50 @echo 'Command `ebook-covert` is provided by calibre package.'51 @echo 'Requires X-forwarding for Qt features used in conversion (ssh -X).'52 @echo 'Do not mind "Invalid value for ..." CSS errors if .mobi renders.'53 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'4344docs:45 $(MAKE) -C docs html
modified:setup.py+11 added-2 removed
46 unmodified lines
47import re48import ast49from setuptools import setup505151_version_re = re.compile(r'__version__\s+=\s+(.*)')5253with open('flask/__init__.py', 'rb') as f:54 version = str(ast.literal_eval(_version_re.search(55 f.read().decode('utf-8')).group(1)))565857setup(58 name='Flask',59 version=version,60 url='https://github.com/pallets/flask/',
12 unmodified lines
73 'Jinja2>=2.4',74 'itsdangerous>=0.21',75 'click>=4.0',76 ],77 extras_require={78 'dev': [79 'blinker',80 'greenlet',81 'pytest>=3',82 'coverage',83 'tox',84 'sphinx',85 'sphinxcontrib-log-cabinet'86 ],87 },88 classifiers=[89 'Development Status :: 4 - Beta',90 'Environment :: Web Environment',91 'Intended Audience :: Developers',
18 unmodified lines
modified:tox.ini+11 added-6 removed
1[tox]2envlist =3 py{36,35,34,33,27,26,py}-release4 py{36,27,py}-release-simplejson3 py{36,35,34,33,27,26,py}4 py{36,27,py}-simplejson5 py{36,33,27,26,py}-devel6 py{36,33,27,26,py}-lowest7 docs-html8 coverage-report
25 unmodified lines
34 pip install -e examples/minitwit -q35 pip install -e examples/patterns/largerapp -q3637 # pytest-cov doesn't seem to play nice with -p38 coverage run -p -m pytest38 coverage run -p -m pytest tests examples3940[testenv:docs-html]41deps =42 sphinx43 flask-sphinx-themes41deps = sphinx42commands = sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html4344[testenv:docs-linkcheck]45deps = sphinx
14 unmodified lines
60commands =61 coverage combine62 coverage report63 codecov6465[testenv:detox]66skip_install = true67deps = detox68commands =69 detox -e py{36,35,34,33,27,26,py},py{36,27,py}-simplejson,py{36,33,27,26,py}-devel,py{36,33,27,26,py}-lowest,docs-html70 tox -e coverage-report