|
1 |
| -import collections.abc |
| 1 | +import collections |
2 | 2 | import io
|
3 | 3 | import os
|
4 | 4 | import errno
|
@@ -43,6 +43,8 @@ def test_pathmod(self):
|
43 | 43 |
|
44 | 44 |
|
45 | 45 | class DummyPurePath(PurePathBase):
|
| 46 | + __slots__ = () |
| 47 | + |
46 | 48 | def __eq__(self, other):
|
47 | 49 | if not isinstance(other, DummyPurePath):
|
48 | 50 | return NotImplemented
|
@@ -660,11 +662,18 @@ def close(self):
|
660 | 662 | super().close()
|
661 | 663 |
|
662 | 664 |
|
| 665 | +DummyPathStatResult = collections.namedtuple( |
| 666 | + 'DummyPathStatResult', |
| 667 | + 'st_mode st_ino st_dev st_nlink st_uid st_gid st_size st_atime st_mtime st_ctime') |
| 668 | + |
| 669 | + |
663 | 670 | class DummyPath(PathBase):
|
664 | 671 | """
|
665 | 672 | Simple implementation of PathBase that keeps files and directories in
|
666 | 673 | memory.
|
667 | 674 | """
|
| 675 | + __slots__ = () |
| 676 | + |
668 | 677 | _files = {}
|
669 | 678 | _directories = {}
|
670 | 679 | _symlinks = {}
|
@@ -693,7 +702,7 @@ def stat(self, *, follow_symlinks=True):
|
693 | 702 | st_mode = stat.S_IFLNK
|
694 | 703 | else:
|
695 | 704 | raise FileNotFoundError(errno.ENOENT, "Not found", str(self))
|
696 |
| - return os.stat_result((st_mode, hash(str(self)), 0, 0, 0, 0, 0, 0, 0, 0)) |
| 705 | + return DummyPathStatResult(st_mode, hash(str(self)), 0, 0, 0, 0, 0, 0, 0, 0) |
697 | 706 |
|
698 | 707 | def open(self, mode='r', buffering=-1, encoding=None,
|
699 | 708 | errors=None, newline=None):
|
@@ -1728,6 +1737,11 @@ def test_walk_symlink_location(self):
|
1728 | 1737 |
|
1729 | 1738 |
|
1730 | 1739 | class DummyPathWithSymlinks(DummyPath):
|
| 1740 | + __slots__ = () |
| 1741 | + |
| 1742 | + # Reduce symlink traversal limit to make tests run faster. |
| 1743 | + _max_symlinks = 20 |
| 1744 | + |
1731 | 1745 | def readlink(self):
|
1732 | 1746 | path = str(self.parent.resolve() / self.name)
|
1733 | 1747 | if path in self._symlinks:
|
|
0 commit comments