Skip to content

Drop old python versions #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
matrix:
# Not all Python versions are available for linux AND x64
# https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, '3.10']
python-version: [3.7, 3.8, 3.9, '3.10']
fail-fast: false

steps:
Expand Down
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Unreleased
----------

Drop support for Python < 3.7.

0.6.0 (2022-05-05)
------------------

Expand Down
8 changes: 8 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
.. image:: https://img.shields.io/pypi/v/pytest-localserver.svg?style=flat
:alt: PyPI Version
:target: https://pypi.python.org/pypi/pytest-django

.. image:: https://img.shields.io/pypi/pyversions/pytest-localserver.svg
:alt: Supported Python versions
:target: https://pypi.python.org/pypi/pytest-django

==================
pytest-localserver
==================
Expand Down
6 changes: 3 additions & 3 deletions pytest_localserver/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, host='127.0.0.1', port=0, application=None, **kwargs):
self._server = make_server(host, port, self.app, **kwargs)
self.server_address = self._server.server_address

super(WSGIServer, self).__init__(
super().__init__(
name=self.__class__,
target=self._server.serve_forever)

Expand Down Expand Up @@ -54,7 +54,7 @@ def __bool__(self):
def _encode_chunk(chunk, charset):
if isinstance(chunk, str):
chunk = chunk.encode(charset)
return '{0:x}'.format(len(chunk)).encode(charset) + b'\r\n' + chunk + b'\r\n'
return f'{len(chunk):x}'.encode(charset) + b'\r\n' + chunk + b'\r\n'


class ContentServer(WSGIServer):
Expand All @@ -79,7 +79,7 @@ class ContentServer(WSGIServer):
"""

def __init__(self, host='127.0.0.1', port=0, ssl_context=None):
super(ContentServer, self).__init__(host, port, self, ssl_context=ssl_context)
super().__init__(host, port, self, ssl_context=ssl_context)
self.content, self.code = ('', 204) # HTTP 204: No Content
self.headers = {}
self.show_post_vars = False
Expand Down
2 changes: 1 addition & 1 deletion pytest_localserver/https.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def __init__(self, host='localhost', port=0,
:param cert: location of file containing server certificate.
"""

super(SecureContentServer, self).__init__(host, port, ssl_context=(key, cert))
super().__init__(host, port, ssl_context=(key, cert))


if __name__ == '__main__': # pragma: no cover
Expand Down
1 change: 0 additions & 1 deletion pytest_localserver/plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf8 -*-
#
# Copyright (C) 2011 Sebastian Rahlf <basti at redtoad dot de>
#
Expand Down
12 changes: 1 addition & 11 deletions pytest_localserver/smtp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf8 -*-
#
# Copyright (C) 2011 Sebastian Rahlf <basti at redtoad dot de>
# with some ideas from http://code.activestate.com/recipes/440690/
Expand Down Expand Up @@ -100,16 +99,7 @@ def is_alive(self):

@property
def accepting(self):
try:
return self.server.is_serving()
except AttributeError:
# asyncio.base_events.Server.is_serving() only exists in Python 3.6
# and up. For Python 3.5, asyncio.base_events.BaseEventLoop.is_running()
# is a close approximation; it should mostly return the same value
# except for brief periods when the server is starting up or shutting
# down. Once we drop support for Python 3.5, this branch becomes
# unnecessary.
return self.loop.is_running()
return self.server.is_serving()

# for aiosmtpd <1.4
if not hasattr(aiosmtpd.controller.Controller, '_trigger_server'):
Expand Down
17 changes: 6 additions & 11 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2663,7 +2663,7 @@
import zlib
import imp

class DictImporter(object):
class DictImporter:
def __init__(self, sources):
self.sources = sources

Expand All @@ -2686,7 +2686,7 @@ def load_module(self, fullname):

co = compile(s, fullname, 'exec')
module = sys.modules.setdefault(fullname, ModuleType(fullname))
module.__file__ = "%s/%s" % (__file__, fullname)
module.__file__ = "{}/{}".format(__file__, fullname)
module.__loader__ = self
if is_pkg:
module.__path__ = [fullname]
Expand All @@ -2701,15 +2701,10 @@ def get_source(self, name):
return res

if __name__ == "__main__":
if sys.version_info >= (3, 0):
exec("def do_exec(co, loc): exec(co, loc)\n")
import pickle
sources = sources.encode("ascii") # ensure bytes
sources = pickle.loads(zlib.decompress(base64.decodebytes(sources)))
else:
import cPickle as pickle
exec("def do_exec(co, loc): exec co in loc\n")
sources = pickle.loads(zlib.decompress(base64.decodestring(sources)))
exec("def do_exec(co, loc): exec(co, loc)\n")
import pickle
sources = sources.encode("ascii") # ensure bytes
sources = pickle.loads(zlib.decompress(base64.decodebytes(sources)))

importer = DictImporter(sources)
sys.meta_path.insert(0, importer)
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ def run(self):
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def _format_chunk(chunk):
if len(r) <= 40:
return r
else:
return r[:13] + '...' + r[-14:] + ' (length {0})'.format(len(chunk))
return r[:13] + '...' + r[-14:] + f' (length {len(chunk)})'


def _compare_chunks(expected, actual):
Expand All @@ -239,7 +239,7 @@ def _compare_chunks(expected, actual):
for i, (e, a) in enumerate(itertools.zip_longest(expected, actual, fillvalue='<end>')):
if e != a:
message += [
' Chunks differ at index {}:'.format(i),
f' Chunks differ at index {i}:',
' Expected: ' + (repr(expected[i:i+5]) + '...' if e != '<end>' else '<end>'),
' Found: ' + (repr(actual[i:i+5]) + '...' if a != '<end>' else '<end>')
]
Expand Down
6 changes: 1 addition & 5 deletions tests/test_smtp.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import smtplib

try: # python 3
from email.mime.text import MIMEText
except ImportError: # python 2?
from email.MIMEText import MIMEText
from email.mime.text import MIMEText

from pytest_localserver import plugin, smtp

Expand Down
4 changes: 1 addition & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py35,py36,py37,py38,py39,py310
envlist = py37,py38,py39,py310
recreate = True
isolated_build = True

Expand All @@ -8,8 +8,6 @@ downloadcache = {toxworkdir}/_download

[gh-actions]
python =
3.5: py35
3.6: py36
3.7: py37
3.8: py38
3.9: py39
Expand Down