clean up flask --version code
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by David Lord · parent 3fd51c6 · Browse files · 3 files·+19 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+19 added−10 removed
- tests:+6 added−5 removed
- other:+13 added−5 removed
Provenance
- Commit
a0ccc47- Tree
02288c6- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
3fd51c6
3 files changed+19 added−10 removed
modified:flask/cli.py+10 added-5 removed
12 unmodified lines13 14 import ast15 import inspect16 import os17+import platform18 import re19 import ssl20 import sys21 import traceback22 from functools import update_wrapper23 from operator import attrgetter24 from threading import Lock, Thread24-import werkzeug25 26 import click27 from werkzeug.utils import import_string28 230 unmodified lines259 260 def get_version(ctx, param, value):261 if not value or ctx.resilient_parsing:262 return263- message = 'Python %(python_version)s\nFlask %(version)s\nWerkzeug %(werkzeug_version)s'263+ import werkzeug264+ message = (265+ 'Python %(python)s\n'266+ 'Flask %(flask)s\n'267+ 'Werkzeug %(werkzeug)s'268+ )269 click.echo(message % {265- 'version': __version__,266- 'python_version': sys.version,267- 'werkzeug_version': werkzeug.__version__,270+ 'python': platform.python_version(),271+ 'flask': __version__,272+ 'werkzeug': werkzeug.__version__,273 }, color=ctx.color)274 ctx.exit()275 276 634 unmodified linesmodified:tests/test_cli.py+6 added-5 removed
239 unmodified lines240 )241 242 243 def test_get_version(test_apps, capsys):244- """Test of get_version."""245- from flask import __version__ as flask_ver246- from sys import version as py_ver244+ from flask import __version__ as flask_version245+ from werkzeug import __version__ as werkzeug_version246+ from platform import python_version247 248 class MockCtx(object):249 resilient_parsing = False250 color = None2 unmodified lines253 254 ctx = MockCtx()255 get_version(ctx, None, "test")256 out, err = capsys.readouterr()257- assert flask_ver in out258- assert py_ver in out257+ assert "Python " + python_version() in out258+ assert "Flask " + flask_version in out259+ assert "Werkzeug " + werkzeug_version in out260 261 262 def test_scriptinfo(test_apps, monkeypatch):263 """Test of ScriptInfo."""314 unmodified linesmodified:CHANGES.rst+3 added
12 unmodified lines13 (ISO-8859-1). This fixes compatibility with Gunicorn, which is14 stricter about header encodings than PEP 3333. (`#2766`_)15 - Allow custom CLIs using ``FlaskGroup`` to set the debug flag without16 it always being overwritten based on environment variables. (`#2765`_)17+- ``flask --version`` outputs Werkzeug's version and simplifies the18+ Python version. (`#2825`_)19 20 .. _#2766: https://github.com/pallets/flask/issues/276621 .. _#2765: https://github.com/pallets/flask/pull/276522+.. _#2825: https://github.com/pallets/flask/pull/282523 24 25 Version 1.0.226 -------------896 unmodified lines