Browse Source

Merge pull request #2558 from pallets/appveyor

add appveyor configuration
pull/2522/merge
David Lord 7 years ago committed by GitHub
parent
commit
eebc0edfdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      .appveyor.yml
  2. 24
      examples/flaskr/tests/test_flaskr.py
  3. 12
      flask/helpers.py

23
.appveyor.yml

@ -0,0 +1,23 @@
environment:
global:
TOXENV: py
matrix:
- PYTHON: C:\Python36
- PYTHON: C:\Python27
init:
- SET PATH=%PYTHON%;%PATH%
install:
- python -m pip install -U pip setuptools wheel tox
build: false
test_script:
- python -m tox
branches:
only:
- master
- /^.*-maintenance$/

24
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):

12
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:

Loading…
Cancel
Save