Skip to content

Commit cafefd3

Browse files
authored
Drop Python 2.7 and 3.4 (#114)
* Update CHANGELOG for 1.0.0 * Introduce pre-commit and linting
1 parent 59add3d commit cafefd3

File tree

14 files changed

+77
-69
lines changed

14 files changed

+77
-69
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
tox_env: [
14-
"py27",
1514
"py35",
1615
"py36",
1716
"py37",
1817
"py38",
1918
"pre",
19+
"linting",
2020
]
2121

2222
include:
23-
- tox_env: "py27"
24-
python: "2.7"
2523
- tox_env: "py35"
2624
python: "3.5"
2725
- tox_env: "py36"
@@ -32,7 +30,9 @@ jobs:
3230
python: "3.8"
3331
- tox_env: "pre"
3432
python: "3.7"
35-
33+
- tox_env: "linting"
34+
python: "3.7"
35+
3636
steps:
3737
- uses: actions/checkout@v1
3838
- name: Set up Python
@@ -46,7 +46,7 @@ jobs:
4646
- name: Test
4747
run: |
4848
tox -e ${{ matrix.tox_env }}
49-
49+
5050
deploy:
5151

5252
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.2.3
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: fix-encoding-pragma
8+
args: [--remove]
9+
- id: check-yaml
10+
- repo: https://github.com/asottile/reorder_python_imports
11+
rev: v1.4.0
12+
hooks:
13+
- id: reorder-python-imports
14+
args: ['--application-directories=.:src', --py3-plus]
15+
- repo: local
16+
hooks:
17+
- id: rst
18+
name: rst
19+
entry: rst-lint --encoding utf-8
20+
files: ^(HOWTORELEASE.rst|README.rst)$
21+
language: python
22+
additional_dependencies: [pygments, restructuredtext_lint]

docs/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Changelog
44
=========
55

6+
1.0.0 (UNRELEASED)
7+
------------------
8+
9+
- Python 2.7 is no longer supported.
10+
611
0.15.1 (2020-02-03)
712
-------------------
813

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# pytest-flask documentation build configuration file, created by
43
# sphinx-quickstart on Thu Feb 19 17:57:27 2015.
@@ -11,8 +10,9 @@
1110
#
1211
# All configuration values have a default; values that are commented out
1312
# serve to show the default.
14-
15-
import sys, os, datetime
13+
import datetime
14+
import os
15+
import sys
1616

1717
# If extensions (or modules to document with autodoc) are in another directory,
1818
# add these directories to sys.path here. If the directory is relative to the

pytest_flask/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
3-
42
from ._version import version as __version__

pytest_flask/fixtures.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
3-
import time
2+
import logging
43
import multiprocessing
5-
import pytest
6-
import socket
7-
import signal
84
import os
9-
import logging
10-
11-
try:
12-
from urllib2 import URLError, urlopen
13-
except ImportError:
14-
from urllib.error import URLError
15-
from urllib.request import urlopen
5+
import signal
6+
import socket
7+
import time
8+
from urllib.error import URLError
9+
from urllib.request import urlopen
1610

11+
import pytest
1712
from flask import _request_ctx_stack
1813

1914

@@ -45,7 +40,7 @@ def test_login(self):
4540
request.cls.client = client
4641

4742

48-
class LiveServer(object):
43+
class LiveServer:
4944
"""The helper class uses to manage live server. Handles creation and
5045
stopping application in a separate process.
5146

pytest_flask/plugin.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
"""
43
A py.test plugin which helps testing Flask applications.
54
@@ -9,18 +8,22 @@
98
import sys
109

1110
import pytest
12-
1311
from flask import json
1412
from werkzeug.utils import cached_property
1513

16-
from .fixtures import (
17-
client, config, accept_json, accept_jsonp, accept_any, accept_mimetype,
18-
client_class, live_server, request_ctx
19-
)
14+
from .fixtures import accept_any
15+
from .fixtures import accept_json
16+
from .fixtures import accept_jsonp
17+
from .fixtures import accept_mimetype
18+
from .fixtures import client
19+
from .fixtures import client_class
20+
from .fixtures import config
21+
from .fixtures import live_server
22+
from .fixtures import request_ctx
2023
from .pytest_compat import getfixturevalue
2124

2225

23-
class JSONResponse(object):
26+
class JSONResponse:
2427
"""Mixin with testing helper methods for JSON responses."""
2528

2629
@cached_property
@@ -38,13 +41,13 @@ def __eq__(self, other):
3841
# separate so we can simplify the code once Python 2 support is dropped
3942
if sys.version_info[0] == 2:
4043
try:
41-
super_eq = super(JSONResponse, self).__eq__
44+
super_eq = super().__eq__
4245
except AttributeError:
4346
return NotImplemented
4447
else:
4548
return super_eq(other)
4649
else:
47-
return super(JSONResponse, self).__eq__(other)
50+
return super().__eq__(other)
4851

4952
def __ne__(self, other):
5053
return not self == other

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
"""
43
pytest-flask
54
============
@@ -102,18 +101,17 @@ def app():
102101
**suggestion**.
103102
104103
"""
105-
import io
106104
import os
107-
import re
108-
from setuptools import setup
105+
109106
from setuptools import find_packages
107+
from setuptools import setup
110108

111109

112110
def read(*parts):
113111
"""Reads the content of the file located at path created from *parts*."""
114112
try:
115-
return io.open(os.path.join(*parts), 'r', encoding='utf-8').read()
116-
except IOError:
113+
return open(os.path.join(*parts), 'r', encoding='utf-8').read()
114+
except OSError:
117115
return ''
118116

119117

tests/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
3-
import pytest
4-
52
from textwrap import dedent
6-
from flask import Flask, jsonify
3+
4+
import pytest
5+
from flask import Flask
6+
from flask import jsonify
77

88

99
pytest_plugins = 'pytester'

0 commit comments

Comments
 (0)