From fa4be14f65751ad821ae2ecae6e242bc22906ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= Date: Thu, 23 Mar 2023 13:23:12 +0100 Subject: [PATCH] Replace TestCase method aliases removed in Python 3.12 Fixes: #568 --- CHANGELOG.md | 2 ++ CONTRIBUTORS.md | 1 + fs/test.py | 2 +- tests/test_move.py | 6 +++--- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef16734e..89e3d825 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ([#535](https://github.com/PyFilesystem/pyfilesystem2/issues/535)). - Fixed a bug where files could be truncated or deleted when moved / copied onto itself. Closes [#546](https://github.com/PyFilesystem/pyfilesystem2/issues/546) +- TestCase method aliases removed in Python 3.12 were replaced and now works with all Python versions. + Closes [#568](https://github.com/PyFilesystem/pyfilesystem2/issues/568) ## [2.4.16] - 2022-05-02 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 78102487..bd1efc01 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -41,6 +41,7 @@ Many thanks to the following developers for contributing to this project: - [@sqwishy](https://github.com/sqwishy) - [Sven Schliesing](https://github.com/muffl0n) - [Thomas Feldmann](https://github.com/tfeldmann) +- [Tomáš Hrnčiar](https://github.com/hrnciar) - [Tim Gates](https://github.com/timgates42/) - [@tkossak](https://github.com/tkossak) - [Todd Levi](https://github.com/televi) diff --git a/fs/test.py b/fs/test.py index 32e6ea5c..9bfe811d 100644 --- a/fs/test.py +++ b/fs/test.py @@ -1082,7 +1082,7 @@ def test_remove(self): self.fs.makedirs("foo/bar/baz/") error_msg = "resource 'foo/bar/egg/test.txt' not found" - assertRaisesRegex = getattr(self, "assertRaisesRegex", self.assertRaisesRegexp) + assertRaisesRegex = getattr(self, "assertRaisesRegex", self.assertRaisesRegex) with assertRaisesRegex(errors.ResourceNotFound, error_msg): self.fs.remove("foo/bar/egg/test.txt") diff --git a/tests/test_move.py b/tests/test_move.py index 8eb1af75..7dd5b114 100644 --- a/tests/test_move.py +++ b/tests/test_move.py @@ -167,7 +167,7 @@ def test_move_file_overwrite(self, _, fs_url): self.assertFalse(src.exists("target.txt")) self.assertFalse(dst.exists("file.txt")) self.assertTrue(dst.exists("target.txt")) - self.assertEquals(dst.readtext("target.txt"), "source content") + self.assertEqual(dst.readtext("target.txt"), "source content") @parameterized.expand([("temp", "temp://"), ("mem", "mem://")]) def test_move_file_overwrite_itself(self, _, fs_url): @@ -177,7 +177,7 @@ def test_move_file_overwrite_itself(self, _, fs_url): tmp.writetext("file.txt", "content") fs.move.move_file(tmp, "file.txt", tmp, "file.txt") self.assertTrue(tmp.exists("file.txt")) - self.assertEquals(tmp.readtext("file.txt"), "content") + self.assertEqual(tmp.readtext("file.txt"), "content") @parameterized.expand([("temp", "temp://"), ("mem", "mem://")]) def test_move_file_overwrite_itself_relpath(self, _, fs_url): @@ -188,7 +188,7 @@ def test_move_file_overwrite_itself_relpath(self, _, fs_url): new_dir.writetext("file.txt", "content") fs.move.move_file(tmp, "dir/../dir/file.txt", tmp, "dir/file.txt") self.assertTrue(tmp.exists("dir/file.txt")) - self.assertEquals(tmp.readtext("dir/file.txt"), "content") + self.assertEqual(tmp.readtext("dir/file.txt"), "content") @parameterized.expand([(True,), (False,)]) def test_move_file_cleanup_on_error(self, cleanup):