Skip to content

Commit d942fb8

Browse files
committed
drop python 2 support
1 parent 2671ebc commit d942fb8

9 files changed

+21
-65
lines changed

.circleci/config.yml

-12
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,6 @@ jobs:
3939

4040
common: &common
4141
jobs:
42-
- sqlite:
43-
name: python27-sqlite
44-
python: '2.7'
45-
- postgres:
46-
name: python27-postgres
47-
python: '2.7'
48-
- mysql:
49-
name: python27-mysql
50-
python: '2.7'
5142
- sqlite:
5243
name: python37-sqlite
5344
python: '3.7'
@@ -61,9 +52,6 @@ common: &common
6152
- python/coverage:
6253
name: coverage
6354
requires:
64-
- python27-sqlite
65-
- python27-postgres
66-
- python27-mysql
6755
- python37-sqlite
6856
- python37-postgres
6957
- python37-mysql

docs/conftest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import textwrap
44
from doctest import REPORT_NDIFF, ELLIPSIS
55
from functools import partial
6-
from mortar_rdb.compat import StringIO
6+
from io import StringIO
77
from os.path import join
88
from unittest import TextTestRunner, makeSuite
99

1010
from sybil import Sybil, Region
11-
from sybil.parsers.doctest import DocTestParser, FIX_BYTE_UNICODE_REPR
11+
from sybil.parsers.doctest import DocTestParser
1212
from sybil.parsers.codeblock import CodeBlockParser
1313
from sybil.parsers.capture import parse_captures
1414
from testfixtures import compare, TempDirectory, Replacer, OutputCapture
@@ -104,7 +104,7 @@ def teardown(namespace):
104104

105105
pytest_collect_file = Sybil(
106106
parsers=[
107-
DocTestParser(optionflags=REPORT_NDIFF|ELLIPSIS|FIX_BYTE_UNICODE_REPR),
107+
DocTestParser(optionflags=REPORT_NDIFF|ELLIPSIS),
108108
parse_captures,
109109
CodeBlockParser(['print_function']),
110110
FileParser('dir'),

mortar_rdb/compat.py

-11
This file was deleted.

mortar_rdb/tests/test_controlled_schema.py

+5-16
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
compare, TempDirectory, ShouldRaise,
66
StringComparison as S
77
)
8-
from mortar_rdb.compat import PY2
98

109
from mortar_rdb.controlled import Source, scan, Config
1110
from mortar_rdb.testing import TestingBase
@@ -42,16 +41,10 @@ def test_class(self):
4241
class SomethingElse:
4342
pass
4443

45-
if PY2:
46-
text = (
47-
"<class mortar_rdb.tests.test_controlled_schema."
48-
"SomethingElse at [0-9a-zA-Z]+>"
49-
)
50-
else:
51-
text = (
52-
"<class 'mortar_rdb.tests.test_controlled_schema."
53-
"TestSource.test_class.<locals>.SomethingElse'>"
54-
)
44+
text = (
45+
"<class 'mortar_rdb.tests.test_controlled_schema."
46+
"TestSource.test_class.<locals>.SomethingElse'>"
47+
)
5548

5649
with ShouldRaise(TypeError(S(
5750
text+" must be a "
@@ -70,11 +63,7 @@ def tearDown(self):
7063
PackageTest.tearDown(self)
7164

7265
def test_doesnt_exist(self):
73-
if PY2:
74-
exc = ImportError
75-
else:
76-
exc = ModuleNotFoundError
77-
with ShouldRaise(exc):
66+
with ShouldRaise(ModuleNotFoundError):
7867
scan('test.package.nothere')
7968

8069
def test_module(self):

mortar_rdb/tests/test_declarative_base.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from sqlalchemy.ext.declarative import DeclarativeMeta
44
from testfixtures import Replacer, ShouldRaise
55
from unittest import TestCase
6-
from mortar_rdb.compat import PY2
76

87

98
class TestGetBase(TestCase):
@@ -29,10 +28,7 @@ def test_existing_base(self):
2928
def test_arguments(self):
3029
# the first parameter to declarative_base :-)
3130
engine = object()
32-
if PY2:
33-
text = 'declarative_base() takes exactly 0 arguments (1 given)'
34-
else:
35-
text = 'declarative_base() takes 0 positional arguments but 1 was given'
31+
text = 'declarative_base() takes 0 positional arguments but 1 was given'
3632

3733
with ShouldRaise(TypeError(text)):
3834
declarative_base(engine)

mortar_rdb/tests/test_register_session.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1+
from unittest import TestCase
2+
3+
from mock import Mock
14
from sqlalchemy import create_engine
25
from sqlalchemy.engine.url import make_url
6+
from testfixtures import (
7+
Replacer, compare, ShouldRaise, LogCapture
8+
)
39
from zope.sqlalchemy.datamanager import STATUS_CHANGED
410

511
from mortar_rdb import register_session
6-
from mortar_rdb.compat import empty_str
712
from mortar_rdb.interfaces import ISession
8-
from mock import Mock
9-
from sqlalchemy.orm.interfaces import SessionExtension
10-
from testfixtures import (
11-
Replacer, Comparison as C, compare, ShouldRaise, LogCapture
12-
)
13-
from unittest import TestCase
14-
from zope.sqlalchemy import ZopeTransactionExtension
13+
1514

1615
class TestUtility(TestCase):
1716

@@ -244,7 +243,7 @@ def test_logging_normal(self):
244243
l.check((
245244
'mortar_rdb',
246245
'INFO',
247-
"Registering session for sqlite:// with name "+empty_str
246+
"Registering session for sqlite:// with name ''"
248247
))
249248

250249
def test_logging_password(self):
@@ -257,7 +256,7 @@ def test_logging_password(self):
257256
'mortar_rdb',
258257
'INFO',
259258
"Registering session for "
260-
"mysql://user:***@localhost/db with name "+empty_str
259+
"mysql://user:***@localhost/db with name ''"
261260
))
262261

263262
def test_logging_username_password_db_same(self):
@@ -270,7 +269,7 @@ def test_logging_username_password_db_same(self):
270269
'mortar_rdb',
271270
'INFO',
272271
"Registering session for "
273-
"mysql://proj:***@localhost/proj with name "+empty_str
272+
"mysql://proj:***@localhost/proj with name ''"
274273
))
275274

276275
def test_logging_name(self):

mortar_rdb/tests/test_utility.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from mortar_rdb import register_session, get_session
2-
from mortar_rdb.compat import empty_str
32
from mortar_rdb.interfaces import ISession
43
from testfixtures.components import TestComponents
54
from sqlalchemy.exc import OperationalError
@@ -203,5 +202,5 @@ def test_logging_functional(self):
203202
l.check((
204203
'mortar_rdb',
205204
'INFO',
206-
"Registering session for sqlite:// with name "+empty_str
205+
"Registering session for sqlite:// with name ''"
207206
))

setup.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
[wheel]
2-
universal=1
3-
41
[tool:pytest]
52
norecursedirs=_build

setup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919
classifiers=[
2020
'Development Status :: 5 - Production/Stable',
2121
'License :: OSI Approved :: MIT License',
22-
'Programming Language :: Python :: 2',
23-
'Programming Language :: Python :: 2.7',
2422
'Programming Language :: Python :: 3',
2523
'Programming Language :: Python :: 3.6',
2624
'Programming Language :: Python :: 3.7',
2725
],
26+
python_requires='>=3.6',
2827
packages=find_packages(),
2928
include_package_data=True,
3029
zip_safe=False,

0 commit comments

Comments
 (0)