From af0d1e02308e9d418dd8a893dfe57bbafbac288f Mon Sep 17 00:00:00 2001 From: Christian Buhtz Date: Wed, 30 Oct 2024 12:09:20 +0100 Subject: [PATCH] build: PyFakeFS minimal version 5.7 (#1911) Thank you to Fedora maintainer @hannes101 bringing this up. Also to PyFakeFS maintainer @mrbean-bremen, "mock" maintainer @xsuchy and the python mailing list folks supporting the diagnostics. --- CHANGES | 3 +- CONTRIBUTING.md | 2 +- common/test/test_lint.py | 3 +- common/test/test_uniquenessset.py | 74 +++++++++++-------------------- 4 files changed, 32 insertions(+), 50 deletions(-) diff --git a/CHANGES b/CHANGES index fba22f388..710af4168 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,6 @@ Back In Time -Version 1.5.3-rc1 - Release Candidate (2024-10-20) +Version 1.5.3-rc2 - Release Candidate (2024-11-??) * Doc: User manual (build with MkDocs) (#1838) (Kosta Vukicevic @stcksmsh) * Doc: User-callback topic in user manual (#1659) * Feature: Support language Interlingua (Occidental) @@ -21,6 +21,7 @@ Version 1.5.3-rc1 - Release Candidate (2024-10-20) * Refactor!: Remove unused config field "user_callback.no_logging" (#1887) * Refactor!: Remove eCryptFS check for home folder (#1855) * Dependency: Remove libnotify-bin (notify-send) (#1156) +* Dependency: PyFakeFS minimal version 5.6 (#1911) * Build: Replace "pycodestyle" linter with "flake8" (#1839) Version 1.5.2 (2024-08-06) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c04b8cd42..c218e4d0f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -157,7 +157,7 @@ the packages provided by the official repository of your GNU/Linux distribution. - `build-essential` - `gzip` - `gettext` - - `python3-pyfakefs` + - `python3-pyfakefs` (>= 5.7) - Optional but recommended: - `pylint` (>= 3.3.0) - `flake8` diff --git a/common/test/test_lint.py b/common/test/test_lint.py index fe5f74818..4a8450b81 100644 --- a/common/test/test_lint.py +++ b/common/test/test_lint.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later # # This file is part of the program "Back In time" which is released under GNU -# General Public License v2 (GPLv2). See file/folder LICENSE or go to +# General Public License v2 (GPLv2). See LICENSES directory or go to # . """Tests using several linters. @@ -47,6 +47,7 @@ 'ssh_max_arg.py', 'version.py', 'test/test_lint.py', + 'test/test_uniquenessset.py', )] # Not all linters do respect PEP8 (e.g. ruff, PyLint) diff --git a/common/test/test_uniquenessset.py b/common/test/test_uniquenessset.py index e6b490722..9a50f2b56 100644 --- a/common/test/test_uniquenessset.py +++ b/common/test/test_uniquenessset.py @@ -4,22 +4,27 @@ # SPDX-License-Identifier: GPL-2.0-or-later # # This file is part of the program "Back In Time" which is released under GNU -# General Public License v2 (GPLv2). See file/folder LICENSE or go to +# General Public License v2 (GPLv2). See LICENSES directory or go to # . """Tests about the uniquenessset module.""" +# pylint: disable=wrong-import-position,C0411,import-outside-toplevel import os import sys +import unittest +import packaging.version +import pyfakefs.fake_filesystem_unittest as pyfakefs_ut from pathlib import Path from tempfile import TemporaryDirectory -import pyfakefs.fake_filesystem_unittest as pyfakefs_ut sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -from uniquenessset import UniquenessSet -import logger +import logger # noqa: E402,RUF100 +from uniquenessset import UniquenessSet # noqa: E402,RUF100 logger.DEBUG = True class General(pyfakefs_ut.TestCase): - # TODO: add test for follow_symlink + """Behavior of class UniquenessSet. + """ + def setUp(self): """Setup a fake filesystem.""" self.setUpPyfakefs(allow_root_user=False) @@ -42,6 +47,23 @@ def _create_unique_file_pairs(self, pairs): return result + @unittest.skipIf(sys.version_info[:2] < (3, 12), + 'Relevant only with Python 3.12 or newer (#1911)') + def test_001_depency_workaround(self): + """Workaround until #1575 is fixed. + + Python 3.13 needs PyFakeFS at min version 5.7 + Python 3.12 needs PyFakeFS at min version 5.6 + + See: + """ + import pyfakefs + pyfakefs_version = packaging.version.parse(pyfakefs.__version__) + min_required_version = packaging.version.parse('5.7.0') + + self.assertTrue(pyfakefs_version >= min_required_version) + def test_ctor_defaults(self): """Default values in constructor.""" with TemporaryDirectory(prefix='bit.') as temp_name: @@ -181,45 +203,3 @@ def test_deep_check(self): self.assertTrue(sut.check(fpa)) self.assertTrue(sut.check(fpb)) - - # def test_something_with_hardlinks(self): - # """Despite its method name, it does not really test for hardlinks. - # That dest origins from the original code base. I see not much value - # in it. The hardlink behavior in the productive code seems untestable - # to me. the ``checkUnique()`` method internally shortens its path if - # there are hardlinks, otherwise it use md5sum. - # """ - # with TemporaryDirectory(prefix='bit.') as temp_name: - # temp_path = Path(temp_name) - - # fpa = temp_path / 'foo' - # fpb = temp_path / 'bar' - - # fpa_hardlink = temp_path / 'hl_foo' - # fpb_hardlink = temp_path / 'hl_bar' - - # fpa.write_text('red') - # fpb.write_text('blue') - # fpa_hardlink.write_text('red') - # fpb_hardlink.write_text('blue') - - # # fpa_hardlink.hardlink_to(fpa) - # # fpb_hardlink.hardlink_to(fpb) - - # # os.utime(fpa_hardlink, - # # times=(fpa.stat().st_atime, fpa.stat().st_mtime)) - # # os.utime(fpb_hardlink, - # # times=(fpb.stat().st_atime, fpb.stat().st_mtime)) - - # # # Be sure that this are hardlinks. (But it does not matter) - # # self.assertEqual(fpa.stat().st_ino, fpa_hardlink.stat().st_ino) - # # self.assertEqual(fpb.stat().st_ino, fpb_hardlink.stat().st_ino) - - # sut = UniquenessSet(deep_check=True, - # follow_symlink=False, - # equal_to='') - - # self.assertTrue(sut.check(fpa)) - # self.assertFalse(sut.check(fpa_hardlink)) - # self.assertTrue(sut.check(fpb)) - # self.assertFalse(sut.check(fpb_hardlink))