The :class:`dircmp` class
-------------------------
-.. class:: dircmp(a, b, ignore=None, hide=None, shallow=True)
+.. class:: dircmp(a, b, ignore=None, hide=None, *, shallow=True)
Construct a new directory comparison object, to compare the directories *a*
and *b*. *ignore* is a list of names to ignore, and defaults to
class dircmp:
"""A class that manages the comparison of 2 directories.
- dircmp(a, b, ignore=None, hide=None, shallow=True)
+ dircmp(a, b, ignore=None, hide=None, *, shallow=True)
A and B are directories.
IGNORE is a list of names to ignore,
defaults to DEFAULT_IGNORES.
in common_dirs.
"""
- def __init__(self, a, b, ignore=None, hide=None, shallow=True): # Initialize
+ def __init__(self, a, b, ignore=None, hide=None, *, shallow=True): # Initialize
self.left = a
self.right = b
if hide is None:
a_x = os.path.join(self.left, x)
b_x = os.path.join(self.right, x)
self.subdirs[x] = self.__class__(a_x, b_x, self.ignore, self.hide,
- self.shallow)
+ shallow=self.shallow)
def phase4_closure(self): # Recursively call phase4() on subdirectories
self.phase4()
import filecmp
import os
+import re
import shutil
import tempfile
import unittest
]
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):