Skip to content

Commit 951b432

Browse files
committed
Changed method names to be PEP 8 conform
1 parent a84a9e6 commit 951b432

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The release versions are PyPi releases.
66
#### New Features
77
* Added new methods to `fake_filesystem.FakeFilesystem` that make real files
88
and directories appear within the fake file system:
9-
`AddRealFile()`, `AddRealDirectory()` and `AddRealPaths()`.
9+
`add_real_file()`, `add_real_directory()` and `add_real_paths()`.
1010
File contents are read from the real file system only when needed.
1111
* Added the CHANGES.md release notes to the release manifest
1212

example_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ def test_scandir(self):
145145
self.assertTrue(entries[2].is_file())
146146

147147
def test_real_file_access(self):
148-
"""Test `example.file_contents()` for a real file after adding it using `AddRealFile()`."""
148+
"""Test `example.file_contents()` for a real file after adding it using `add_real_file()`."""
149149
real_file = __file__
150150
with REAL_OPEN(real_file, 'rb') as f:
151151
real_contents = f.read()
152152
self.assertRaises(IOError, example.file_contents, real_file)
153-
self.fs.AddRealFile(real_file)
153+
self.fs.add_real_file(real_file)
154154
self.assertEqual(example.file_contents(real_file), real_contents)
155155

156156

fake_filesystem_test.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4452,23 +4452,23 @@ def setUp(self):
44524452

44534453
def testAddNonExistingRealFileRaises(self):
44544454
nonexisting_path = os.path.join('nonexisting', 'test.txt')
4455-
self.assertRaises(OSError, self.filesystem.AddRealFile, nonexisting_path)
4455+
self.assertRaises(OSError, self.filesystem.add_real_file, nonexisting_path)
44564456
self.assertFalse(self.filesystem.Exists(nonexisting_path))
44574457

44584458
def testAddNonExistingRealDirectoryRaises(self):
44594459
nonexisting_path = '/nonexisting'
4460-
self.assertRaisesIOError(errno.ENOENT, self.filesystem.AddRealDirectory, nonexisting_path)
4460+
self.assertRaisesIOError(errno.ENOENT, self.filesystem.add_real_directory, nonexisting_path)
44614461
self.assertFalse(self.filesystem.Exists(nonexisting_path))
44624462

44634463
def testExistingFakeFileRaises(self):
44644464
real_file_path = __file__
44654465
self.filesystem.CreateFile(real_file_path)
4466-
self.assertRaisesIOError(errno.EEXIST, self.filesystem.AddRealFile, real_file_path)
4466+
self.assertRaisesIOError(errno.EEXIST, self.filesystem.add_real_file, real_file_path)
44674467

44684468
def testExistingFakeDirectoryRaises(self):
44694469
real_dir_path = os.path.dirname(__file__)
44704470
self.filesystem.CreateDirectory(real_dir_path)
4471-
self.assertRaisesOSError(errno.EEXIST, self.filesystem.AddRealDirectory, real_dir_path)
4471+
self.assertRaisesOSError(errno.EEXIST, self.filesystem.add_real_directory, real_dir_path)
44724472

44734473
def checkFakeFileStat(self, fake_file, real_file_path):
44744474
self.assertTrue(self.filesystem.Exists(real_file_path))
@@ -4502,22 +4502,22 @@ def checkWritableFile(self, fake_file, real_file_path):
45024502

45034503
def testAddExistingRealFileReadOnly(self):
45044504
real_file_path = __file__
4505-
fake_file = self.filesystem.AddRealFile(real_file_path)
4505+
fake_file = self.filesystem.add_real_file(real_file_path)
45064506
self.checkFakeFileStat(fake_file, real_file_path)
45074507
self.assertEqual(fake_file.st_mode & 0o333, 0)
45084508
self.checkReadOnlyFile(fake_file, real_file_path)
45094509

45104510
def testAddExistingRealFileReadWrite(self):
45114511
real_file_path = os.path.realpath(__file__)
4512-
fake_file = self.filesystem.AddRealFile(real_file_path, read_only=False)
4512+
fake_file = self.filesystem.add_real_file(real_file_path, read_only=False)
45134513

45144514
self.checkFakeFileStat(fake_file, real_file_path)
45154515
self.assertEqual(fake_file.st_mode, os.stat(real_file_path).st_mode)
45164516
self.checkWritableFile(fake_file, real_file_path)
45174517

45184518
def testAddExistingRealDirectoryReadOnly(self):
45194519
real_dir_path = os.path.join(os.path.dirname(__file__), 'pyfakefs')
4520-
fake_dir = self.filesystem.AddRealDirectory(real_dir_path)
4520+
fake_dir = self.filesystem.add_real_directory(real_dir_path)
45214521
self.assertTrue(self.filesystem.Exists(real_dir_path))
45224522
self.assertTrue(self.filesystem.Exists(os.path.join(real_dir_path, 'fake_filesystem.py')))
45234523
self.assertTrue(self.filesystem.Exists(os.path.join(real_dir_path, 'fake_pathlib.py')))
@@ -4529,14 +4529,14 @@ def testAddExistingRealDirectoryReadOnly(self):
45294529

45304530
def testAddExistingRealDirectoryTree(self):
45314531
real_dir_path = os.path.dirname(__file__)
4532-
self.filesystem.AddRealDirectory(real_dir_path)
4532+
self.filesystem.add_real_directory(real_dir_path)
45334533
self.assertTrue(self.filesystem.Exists(os.path.join(real_dir_path, 'fake_filesystem_test.py')))
45344534
self.assertTrue(self.filesystem.Exists(os.path.join(real_dir_path, 'pyfakefs', 'fake_filesystem.py')))
45354535
self.assertTrue(self.filesystem.Exists(os.path.join(real_dir_path, 'pyfakefs', '__init__.py')))
45364536

45374537
def testAddExistingRealDirectoryReadWrite(self):
45384538
real_dir_path = os.path.join(os.path.dirname(__file__), 'pyfakefs')
4539-
self.filesystem.AddRealDirectory(real_dir_path, read_only=False)
4539+
self.filesystem.add_real_directory(real_dir_path, read_only=False)
45404540
self.assertTrue(self.filesystem.Exists(real_dir_path))
45414541
self.assertTrue(self.filesystem.Exists(os.path.join(real_dir_path, 'fake_filesystem.py')))
45424542
self.assertTrue(self.filesystem.Exists(os.path.join(real_dir_path, 'fake_pathlib.py')))
@@ -4549,7 +4549,7 @@ def testAddExistingRealDirectoryReadWrite(self):
45494549
def testAddExistingRealPathsReadOnly(self):
45504550
real_file_path = os.path.realpath(__file__)
45514551
real_dir_path = os.path.join(os.path.dirname(__file__), 'pyfakefs')
4552-
self.filesystem.AddRealPaths([real_file_path, real_dir_path])
4552+
self.filesystem.add_real_paths([real_file_path, real_dir_path])
45534553

45544554
fake_file = self.filesystem.ResolveObject(real_file_path)
45554555
self.checkFakeFileStat(fake_file, real_file_path)
@@ -4563,7 +4563,7 @@ def testAddExistingRealPathsReadOnly(self):
45634563
def testAddExistingRealPathsReadWrite(self):
45644564
real_file_path = os.path.realpath(__file__)
45654565
real_dir_path = os.path.join(os.path.dirname(__file__), 'pyfakefs')
4566-
self.filesystem.AddRealPaths([real_file_path, real_dir_path], read_only=False)
4566+
self.filesystem.add_real_paths([real_file_path, real_dir_path], read_only=False)
45674567

45684568
fake_file = self.filesystem.ResolveObject(real_file_path)
45694569
self.checkFakeFileStat(fake_file, real_file_path)

pyfakefs/fake_filesystem.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def __init__(self, name, st_mode=stat.S_IFREG | PERM_DEF_FILE,
210210
self.st_uid = None
211211
self.st_gid = None
212212

213-
# members changed only by _CreateFile() to implement AddRealFile()
213+
# members changed only by _CreateFile() to implement add_real_file()
214214
self.read_from_real_fs = False
215215
self.file_path = None
216216

@@ -1618,7 +1618,7 @@ def CreateFile(self, file_path, st_mode=stat.S_IFREG | PERM_DEF_FILE,
16181618
"""
16191619
return self._CreateFile(file_path, st_mode, contents, st_size, create_missing_dirs, apply_umask, encoding)
16201620

1621-
def AddRealFile(self, file_path, read_only=True):
1621+
def add_real_file(self, file_path, read_only=True):
16221622
"""Create file_path, including all the parent directories along the way, for a file
16231623
existing in the real file system without reading the contents, which will be read on demand.
16241624
New in pyfakefs 3.2.
@@ -1641,7 +1641,7 @@ def AddRealFile(self, file_path, read_only=True):
16411641
return self._CreateFile(file_path, contents=None, read_from_real_fs=True,
16421642
st_mode=mode, real_stat=real_stat)
16431643

1644-
def AddRealDirectory(self, dir_path, read_only=True):
1644+
def add_real_directory(self, dir_path, read_only=True):
16451645
"""Create fake directory for the existing directory at path, and entries for all contained
16461646
files in the real file system.
16471647
New in pyfakefs 3.2.
@@ -1664,11 +1664,11 @@ def AddRealDirectory(self, dir_path, read_only=True):
16641664
self.CreateDirectory(dir_path)
16651665
for base, _, files in os.walk(dir_path):
16661666
for fileEntry in files:
1667-
self.AddRealFile(os.path.join(base, fileEntry), read_only)
1667+
self.add_real_file(os.path.join(base, fileEntry), read_only)
16681668

1669-
def AddRealPaths(self, path_list, read_only=True):
1669+
def add_real_paths(self, path_list, read_only=True):
16701670
"""Convenience method to add several files and directories from the real file system
1671-
in the fake file system. See `AddRealFile()` and `AddRealDirectory()`.
1671+
in the fake file system. See `add_real_file()` and `add_real_directory()`.
16721672
New in pyfakefs 3.2.
16731673
16741674
Args:
@@ -1683,9 +1683,9 @@ def AddRealPaths(self, path_list, read_only=True):
16831683
"""
16841684
for path in path_list:
16851685
if os.path.isdir(path):
1686-
self.AddRealDirectory(path, read_only)
1686+
self.add_real_directory(path, read_only)
16871687
else:
1688-
self.AddRealFile(path, read_only)
1688+
self.add_real_file(path, read_only)
16891689

16901690
def _CreateFile(self, file_path, st_mode=stat.S_IFREG | PERM_DEF_FILE,
16911691
contents='', st_size=None, create_missing_dirs=True,

0 commit comments

Comments
 (0)