From e296a67a08810d2395e8baa2c1b82ce5508fe808 Mon Sep 17 00:00:00 2001 From: David Lord Date: Sat, 16 Dec 2017 07:17:13 -0800 Subject: [PATCH 1/5] add appveyor configuration --- .appveyor.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 00000000..102ff5c3 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,20 @@ +environment: + global: + TOXENV: "py" + + matrix: + - PYTHON: "C:\\Python36" + - PYTHON: "C:\\Python27" + +install: + - "%PYTHON%\\python.exe -m pip install -U pip setuptools wheel tox" + +build: false + +test_script: + - "%PYTHON%\\python.exe -m tox" + +branches: + only: + - master + - /^.*-maintenance$/ From 411b08ff8bcd30aca15f2dc0be5f633879c633db Mon Sep 17 00:00:00 2001 From: Hsiaoming Yang Date: Sun, 17 Dec 2017 02:43:06 +0900 Subject: [PATCH 2/5] Better appveyor config --- .appveyor.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 102ff5c3..107fb409 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -3,16 +3,21 @@ environment: TOXENV: "py" matrix: - - PYTHON: "C:\\Python36" - PYTHON: "C:\\Python27" + - PYTHON: "C:\\Python35" + - PYTHON: "C:\\Python36" + +init: + - SET PATH=%PYTHON%;%PATH% + - python -c "import sys;sys.stdout.write(sys.version)" install: - - "%PYTHON%\\python.exe -m pip install -U pip setuptools wheel tox" + - python -m pip install -U pip setuptools wheel tox build: false test_script: - - "%PYTHON%\\python.exe -m tox" + - python -m tox branches: only: From 3012d20a3f24c8c8afa4be754d6f198506f72286 Mon Sep 17 00:00:00 2001 From: David Lord Date: Thu, 4 Jan 2018 07:29:15 -0800 Subject: [PATCH 3/5] cleanup --- .appveyor.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 107fb409..3a7d2f63 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,15 +1,13 @@ environment: global: - TOXENV: "py" + TOXENV: py matrix: - - PYTHON: "C:\\Python27" - - PYTHON: "C:\\Python35" - - PYTHON: "C:\\Python36" + - PYTHON: C:\Python36 + - PYTHON: C:\Python27 init: - SET PATH=%PYTHON%;%PATH% - - python -c "import sys;sys.stdout.write(sys.version)" install: - python -m pip install -U pip setuptools wheel tox From ffca68fc86718b133668f341ddd8c2635d7e29ec Mon Sep 17 00:00:00 2001 From: David Lord Date: Fri, 5 Jan 2018 12:36:01 -0800 Subject: [PATCH 4/5] fix windows failure to remove temp file --- examples/flaskr/tests/test_flaskr.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/examples/flaskr/tests/test_flaskr.py b/examples/flaskr/tests/test_flaskr.py index b5ade2ec..e1e9a4e7 100644 --- a/examples/flaskr/tests/test_flaskr.py +++ b/examples/flaskr/tests/test_flaskr.py @@ -17,33 +17,25 @@ from flaskr.blueprints.flaskr import init_db @pytest.fixture -def app(request): - - db_fd, temp_db_location = tempfile.mkstemp() +def app(): + db_fd, db_path = tempfile.mkstemp() config = { - 'DATABASE': temp_db_location, + 'DATABASE': db_path, 'TESTING': True, - 'DB_FD': db_fd } - app = create_app(config=config) with app.app_context(): init_db() yield app + os.close(db_fd) + os.unlink(db_path) -@pytest.fixture -def client(request, app): - - client = app.test_client() - - def teardown(): - os.close(app.config['DB_FD']) - os.unlink(app.config['DATABASE']) - request.addfinalizer(teardown) - return client +@pytest.fixture +def client(app): + return app.test_client() def login(client, username, password): From 333865ea34acefbca565170881ff403fd7840d57 Mon Sep 17 00:00:00 2001 From: David Lord Date: Fri, 5 Jan 2018 13:27:31 -0800 Subject: [PATCH 5/5] windows python 2 doesn't provide inet_pton --- flask/helpers.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/flask/helpers.py b/flask/helpers.py index f1011ad0..067e97cb 100644 --- a/flask/helpers.py +++ b/flask/helpers.py @@ -42,8 +42,7 @@ from jinja2 import FileSystemLoader from .signals import message_flashed from .globals import session, _request_ctx_stack, _app_ctx_stack, \ current_app, request -from ._compat import string_types, text_type - +from ._compat import string_types, text_type, PY2 # sentinel _missing = object() @@ -1002,12 +1001,21 @@ def total_seconds(td): def is_ip(value): """Determine if the given string is an IP address. + Python 2 on Windows doesn't provide ``inet_pton``, so this only + checks IPv4 addresses in that environment. + :param value: value to check :type value: str :return: True if string is an IP address :rtype: bool """ + if PY2 and os.name == 'nt': + try: + socket.inet_aton(value) + return True + except socket.error: + return False for family in (socket.AF_INET, socket.AF_INET6): try: