diff --git a/.coveragerc.py2 b/.coveragerc.py2 deleted file mode 100644 index 5cdeb73..0000000 --- a/.coveragerc.py2 +++ /dev/null @@ -1,4 +0,0 @@ -[report] -exclude_lines = - # pragma: no cover - if six.PY3: diff --git a/.coveragerc.py3 b/.coveragerc.py3 index 2c0d124..23e8aa0 100644 --- a/.coveragerc.py3 +++ b/.coveragerc.py3 @@ -1,4 +1,3 @@ [report] exclude_lines = pragma: no cover - if six.PY2: diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7014492..ee11118 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [2.7, 3.5, 3.6] + python: [3.7, 3.12] steps: - name: Checkout source code uses: actions/checkout@v2 diff --git a/HACKING.rst b/HACKING.rst index 1502cd5..092bd1a 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -21,14 +21,6 @@ Then you can run tests with: make -The default Python version is 2, to run tests against Python 3 just -prepend `PYTHON=python3` to the make commands above, for -example: - -.. code:: shell - - PYTHON=python3 make - Tox --- diff --git a/Makefile b/Makefile index 4b675c4..0383a35 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,7 @@ -PYTHON ?= python -PYTHON_MAJOR = $(shell $(PYTHON) -c "import sys; print(sys.version_info.major)") - # These paths are valid on Debian-based systems, on other systems you # might have to set these variables from the command line. -COVERAGE ?= $(PYTHON)-coverage -SPHINXBUILD ?= /usr/share/sphinx/scripts/python$(PYTHON_MAJOR)/sphinx-build +COVERAGE ?= python3-coverage +SPHINXBUILD ?= /usr/share/sphinx/scripts/python3/sphinx-build SOURCE = systemfixtures @@ -13,27 +10,20 @@ all: check check-doc check: rm -f .coverage $(COVERAGE) run --source=$(SOURCE) -m testtools.run discover - $(COVERAGE) report -m --fail-under=100 --rcfile=.coveragerc.py$(PYTHON_MAJOR) + $(COVERAGE) report -m --fail-under=100 --rcfile=.coveragerc.py3 check-doc: SPHINXBUILD=$(SPHINXBUILD) $(MAKE) -C doc doctest -dependencies: dependencies-python$(PYTHON_MAJOR) - sudo apt-get install \ - $(PYTHON)-pbr \ - $(PYTHON)-six \ - $(PYTHON)-fixtures \ - $(PYTHON)-testtools \ - $(PYTHON)-requests-mock \ - $(PYTHON)-fakesleep \ - $(PYTHON)-coverage \ - $(PYTHON)-sphinx - -dependencies-python2: +dependencies: sudo apt-get install \ - $(PYTHON)-subprocess32 - -dependencies-python3): + python3-pbr \ + python3-fixtures \ + python3-testtools \ + python3-requests-mock \ + python3-fakesleep \ + python3-coverage \ + python3-sphinx clean: rm -rf $(SOURCE).egg-info dist @@ -41,4 +31,4 @@ clean: find -type f -name "*.pyc" | xargs rm -f find -type d -name "__pycache_" | xargs rm -rf -.PHONY: all check check-doc dependencies dependencies-python2 dependencies-python3 +.PHONY: all check check-doc dependencies diff --git a/doc/conf.py b/doc/conf.py index e18b433..48b374e 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -18,8 +18,6 @@ import re import doctest -import six - # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -300,16 +298,6 @@ class SixOutputChecker(OutputChecker): """ def check_output(self, want, got, optionflags): - if six.PY2: - if want == "12\n": # write() doesn't return number of bytes on PY2 - want = "" - - want = re.sub("PermissionError: (.*)", "OSError: \\1", want) - want = re.sub("'0o(.+)'\n", "'0\\1'\n", want) - want = re.sub("b'(.*?)'", "'\\1'", want) - - got = re.sub("u'(.*?)'", "'\\1'", got) - return OutputChecker.check_output(self, want, got, optionflags) diff --git a/requirements.txt b/requirements.txt index fbe1047..cf78879 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,5 @@ pbr -six fixtures testtools requests-mock fakesleep -subprocess32; python_version < '3.5' diff --git a/systemfixtures/executable.py b/systemfixtures/executable.py index 3ae433a..f49b159 100644 --- a/systemfixtures/executable.py +++ b/systemfixtures/executable.py @@ -1,7 +1,6 @@ import os import socket - -import six +import subprocess from testtools.content import Content from testtools.content_type import UTF8_TEXT @@ -11,10 +10,6 @@ TempDir, ) -if six.PY2: - import subprocess32 as subprocess -if six.PY3: - import subprocess class FakeExecutable(Fixture): diff --git a/systemfixtures/filesystem.py b/systemfixtures/filesystem.py index f26a3ee..eb6fa56 100644 --- a/systemfixtures/filesystem.py +++ b/systemfixtures/filesystem.py @@ -1,5 +1,5 @@ import os -import six +from os import DirEntry from fixtures import ( Fixture, @@ -8,15 +8,8 @@ from ._overlay import Overlay -if six.PY2: - BUILTIN_OPEN = "__builtin__.open" -if six.PY3: - BUILTIN_OPEN = "builtins.open" - from os import DirEntry - - GENERIC_APIS = ( - BUILTIN_OPEN, + "builtins.open", "glob.glob", "os.mkdir", "os.rmdir", @@ -45,11 +38,7 @@ def _setUp(self): self._paths = {} self._ownership = {} - if six.PY2: - # Python 2 doesn't support a fd argument - condition = self._is_fake_path - if six.PY3: - condition = self._is_fake_path_or_fd + condition = self._is_fake_path_or_fd for api in GENERIC_APIS: self.useFixture(Overlay(api, self._generic, condition)) @@ -135,14 +124,12 @@ def _is_fake_fd(self, fileno, *args, **kwargs): path = self._path_from_fd(fileno) return path.startswith(self.root.path) - if six.PY3: - - def _is_fake_path_or_fd(self, path, *args, **kwargs): - if isinstance(path, int): - path = self._path_from_fd(path) - elif isinstance(path, DirEntry): - path = path.name - return self._is_fake_path(path) + def _is_fake_path_or_fd(self, path, *args, **kwargs): + if isinstance(path, int): + path = self._path_from_fd(path) + elif isinstance(path, DirEntry): + path = path.name + return self._is_fake_path(path) def _is_fake_symlink(self, src, dst, *args, **kwargs): return self._is_fake_path(src) or self._is_fake_path(dst) diff --git a/systemfixtures/processes/fixture.py b/systemfixtures/processes/fixture.py index e2138d5..49fcfe1 100644 --- a/systemfixtures/processes/fixture.py +++ b/systemfixtures/processes/fixture.py @@ -1,4 +1,3 @@ -import six import subprocess from fixtures import FakePopen @@ -53,11 +52,9 @@ class _FakeProcessWithMissingAPIs(popen.FakeProcess): is merged upstream. """ - if six.PY3: - - @property - def args(self): - return self._args["args"] + @property + def args(self): + return self._args["args"] def poll(self): return self.returncode diff --git a/systemfixtures/tests/test_filesystem.py b/systemfixtures/tests/test_filesystem.py index ec3d26a..e4e9d1b 100644 --- a/systemfixtures/tests/test_filesystem.py +++ b/systemfixtures/tests/test_filesystem.py @@ -1,7 +1,6 @@ import glob import os import sqlite3 -import six import shutil from testtools import TestCase, skipIf @@ -17,10 +16,6 @@ from ..matchers import HasOwnership -if six.PY2: - PermissionError = OSError - - class FakeFilesystemTest(TestCase): def setUp(self): @@ -103,14 +98,12 @@ def test_copytree(self): self.assertEqual( sorted(os.listdir("./doc")), sorted(os.listdir("/foo"))) - if six.PY3: - - def test_listdir_with_fd(self): - self.fs.add("/foo") - os.makedirs("/foo/bar") - fd = os.open("/foo", os.O_RDONLY) - self.addCleanup(os.close, fd) - self.assertEqual(["bar"], os.listdir(fd)) + def test_listdir_with_fd(self): + self.fs.add("/foo") + os.makedirs("/foo/bar") + fd = os.open("/foo", os.O_RDONLY) + self.addCleanup(os.close, fd) + self.assertEqual(["bar"], os.listdir(fd)) def test_readlink_to_real_path(self): self.fs.add("/foo") diff --git a/tox.ini b/tox.ini index 2c9cac7..988cfe1 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py35,py36 +envlist = py37,py312 skipsdist = True [testenv] @@ -11,5 +11,7 @@ setenv = SPHINXBUILD=sphinx-build whitelist_externals = make +allowlist_externals = + make commands = make