mirror of
https://github.com/python/cpython.git
synced 2025-10-21 22:22:48 +00:00
gh-57141: Make shallow argument to filecmp.dircmp keyword-only (#121767)
It is our general practice to make new optional parameters keyword-only, even if the existing parameters are all positional-or-keyword. Passing this parameter as positional would look confusing and could be error-prone if additional parameters are added in the future.
This commit is contained in:
parent
7982363b47
commit
50eec501fe
4 changed files with 18 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
import filecmp
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
@ -277,6 +278,17 @@ class DirCompareTestCase(unittest.TestCase):
|
|||
]
|
||||
self._assert_report(d.report, expected_report)
|
||||
|
||||
def test_dircmp_shallow_is_keyword_only(self):
|
||||
with self.assertRaisesRegex(
|
||||
TypeError,
|
||||
re.escape("dircmp.__init__() takes from 3 to 5 positional arguments but 6 were given"),
|
||||
):
|
||||
filecmp.dircmp(self.dir, self.dir_same, None, None, True)
|
||||
self.assertIsInstance(
|
||||
filecmp.dircmp(self.dir, self.dir_same, None, None, shallow=True),
|
||||
filecmp.dircmp,
|
||||
)
|
||||
|
||||
def test_dircmp_subdirs_type(self):
|
||||
"""Check that dircmp.subdirs respects subclassing."""
|
||||
class MyDirCmp(filecmp.dircmp):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue