From 8980c4c997e0c826cc994bd16ecf8c74b74e3bd2 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 15 Sep 2024 16:43:52 -0400 Subject: [PATCH] tests: actually be correct about portably detecting assertRaisesRegex using getattr to conditionally get the non-deprecated version does not work when the deprecated version actually disappears. The codebase already uses the six.py portability library, which handles this for you. Use it here too! --- fs/test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/test.py b/fs/test.py index 32e6ea5c..850b3c17 100644 --- a/fs/test.py +++ b/fs/test.py @@ -1082,8 +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) - with assertRaisesRegex(errors.ResourceNotFound, error_msg): + with six.assertRaisesRegex(self, errors.ResourceNotFound, error_msg): self.fs.remove("foo/bar/egg/test.txt") def test_removedir(self):