Skip to content

Commit 851ef85

Browse files
committed
Changed whitespace to conform to pep-8
- auto-format done by PyCharm
1 parent 0e6704e commit 851ef85

15 files changed

+7684
-7667
lines changed

all_tests.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,24 @@
2828

2929

3030
class AllTests(unittest.TestSuite):
31-
"""A test suite that runs all tests for pyfakefs at once."""
32-
33-
def suite(self): # pylint: disable-msg=C6409
34-
loader = unittest.defaultTestLoader
35-
self.addTests([
36-
loader.loadTestsFromModule(fake_filesystem_test),
37-
loader.loadTestsFromModule(fake_filesystem_glob_test),
38-
loader.loadTestsFromModule(fake_filesystem_shutil_test),
39-
loader.loadTestsFromModule(fake_tempfile_test),
40-
loader.loadTestsFromModule(fake_filesystem_vs_real_test),
41-
loader.loadTestsFromModule(fake_filesystem_unittest_test),
42-
loader.loadTestsFromModule(example_test),
43-
])
44-
return self
31+
"""A test suite that runs all tests for pyfakefs at once."""
32+
33+
def suite(self): # pylint: disable-msg=C6409
34+
loader = unittest.defaultTestLoader
35+
self.addTests([
36+
loader.loadTestsFromModule(fake_filesystem_test),
37+
loader.loadTestsFromModule(fake_filesystem_glob_test),
38+
loader.loadTestsFromModule(fake_filesystem_shutil_test),
39+
loader.loadTestsFromModule(fake_tempfile_test),
40+
loader.loadTestsFromModule(fake_filesystem_vs_real_test),
41+
loader.loadTestsFromModule(fake_filesystem_unittest_test),
42+
loader.loadTestsFromModule(example_test),
43+
])
44+
return self
45+
4546

4647
if __name__ == '__main__':
47-
import sys
48-
result = unittest.TextTestRunner(verbosity=2).run(AllTests().suite())
49-
sys.exit(int(not result.wasSuccessful()))
48+
import sys
49+
50+
result = unittest.TextTestRunner(verbosity=2).run(AllTests().suite())
51+
sys.exit(int(not result.wasSuccessful()))

example.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040
import glob
4141
import shutil
4242

43+
4344
def create_file(path):
44-
'''Create the specified file and add some content to it. Use the `open()`
45+
"""Create the specified file and add some content to it. Use the `open()`
4546
built in function.
4647
4748
For example, the following file operations occur in the fake file system.
@@ -60,13 +61,14 @@ def create_file(path):
6061
>>> with open('/test/file.txt') as f:
6162
... f.readlines()
6263
["This is test file '/test/file.txt'.\\n", 'It was created using the open() function.\\n']
63-
'''
64+
"""
6465
with open(path, 'w') as f:
6566
f.write("This is test file '{0}'.\n".format(path))
6667
f.write("It was created using the open() function.\n")
6768

69+
6870
def delete_file(path):
69-
'''Delete the specified file.
71+
"""Delete the specified file.
7072
7173
For example:
7274
@@ -79,11 +81,12 @@ def delete_file(path):
7981
>>> delete_file('/test/file.txt')
8082
>>> os.path.exists('/test/file.txt')
8183
False
82-
'''
84+
"""
8385
os.remove(path)
8486

87+
8588
def path_exists(path):
86-
'''Return True if the specified file exists.
89+
"""Return True if the specified file exists.
8790
8891
For example:
8992
@@ -98,11 +101,12 @@ def path_exists(path):
98101
>>> create_file('/test/file.txt')
99102
>>> path_exists('/test/file.txt')
100103
True
101-
'''
104+
"""
102105
return os.path.exists(path)
103106

107+
104108
def get_glob(glob_path):
105-
r'''Return the list of paths matching the specified glob expression.
109+
r"""Return the list of paths matching the specified glob expression.
106110
107111
For example:
108112
@@ -119,9 +123,10 @@ def get_glob(glob_path):
119123
... # UNIX style path
120124
... file_names == ['/test/file1.txt', '/test/file2.txt']
121125
True
122-
'''
126+
"""
123127
return glob.glob(glob_path)
124128

129+
125130
def rm_tree(path):
126-
'''Delete the specified file hierarchy.'''
131+
"""Delete the specified file hierarchy."""
127132
shutil.rmtree(path)

example_test.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import os
2424
import sys
25+
2526
if sys.version_info < (2, 7):
2627
import unittest2 as unittest
2728
else:
@@ -33,15 +34,15 @@
3334

3435

3536
def load_tests(loader, tests, ignore):
36-
'''Load the pyfakefs/example.py doctest tests into unittest.'''
37+
"""Load the pyfakefs/example.py doctest tests into unittest."""
3738
return fake_filesystem_unittest.load_doctests(loader, tests, ignore, example)
3839

3940

40-
class TestExample(fake_filesystem_unittest.TestCase): # pylint: disable=R0904
41-
'''Test the example module.'''
41+
class TestExample(fake_filesystem_unittest.TestCase): # pylint: disable=R0904
42+
"""Test the example module."""
4243

4344
def setUp(self):
44-
'''Invoke the :py:class:`pyfakefs.fake_filesystem_unittest.TestCase`
45+
"""Invoke the :py:class:`pyfakefs.fake_filesystem_unittest.TestCase`
4546
`self.setUp()` method. This defines:
4647
4748
* Attribute `self.fs`, an instance of \
@@ -50,15 +51,15 @@ def setUp(self):
5051
* Attribute `self.stubs`, an instance of \
5152
:py:class:`mox.stubout.StubOutForTesting`. Use this if you need to
5253
define additional stubs.
53-
'''
54+
"""
5455
self.setUpPyfakefs()
5556

5657
def tearDown(self):
5758
# No longer need self.tearDownPyfakefs()
5859
pass
5960

6061
def test_create_file(self):
61-
'''Test example.create_file()'''
62+
"""Test example.create_file()"""
6263
# The os module has been replaced with the fake os module so all of the
6364
# following occurs in the fake filesystem.
6465
self.assertFalse(os.path.isdir('/test'))
@@ -70,14 +71,14 @@ def test_create_file(self):
7071
self.assertTrue(os.path.exists('/test/file.txt'))
7172

7273
def test_delete_file(self):
73-
'''Test example.delete_file()
74+
"""Test example.delete_file()
7475
7576
`self.fs.CreateFile()` is convenient because it automatically creates
7677
directories in the fake file system and allows you to specify the file
7778
contents.
7879
7980
You could also use `open()` or `file()`.
80-
'''
81+
"""
8182
self.fs.CreateFile('/test/full.txt',
8283
contents='First line\n'
8384
'Second Line\n')
@@ -86,25 +87,25 @@ def test_delete_file(self):
8687
self.assertFalse(os.path.exists('/test/full.txt'))
8788

8889
def test_file_exists(self):
89-
'''Test example.path_exists()
90+
"""Test example.path_exists()
9091
9192
`self.fs.CreateFile()` is convenient because it automatically creates
9293
directories in the fake file system and allows you to specify the file
9394
contents.
9495
9596
You could also use `open()` or `file()` if you wanted.
96-
'''
97+
"""
9798
self.assertFalse(example.path_exists('/test/empty.txt'))
9899
self.fs.CreateFile('/test/empty.txt')
99100
self.assertTrue(example.path_exists('/test/empty.txt'))
100101

101102
def test_get_globs(self):
102-
'''Test example.get_glob()
103+
"""Test example.get_glob()
103104
104105
`self.fs.CreateDirectory()` creates directories. However, you might
105106
prefer the familiar `os.makedirs()`, which also works fine on the fake
106107
file system.
107-
'''
108+
"""
108109
self.assertFalse(os.path.isdir('/test'))
109110
self.fs.CreateDirectory('/test/dir1/dir2a')
110111
self.assertTrue(os.path.isdir('/test/dir1/dir2a'))
@@ -113,7 +114,7 @@ def test_get_globs(self):
113114
self.assertTrue(os.path.isdir('/test/dir1/dir2b'))
114115

115116
self.assertEqual(example.get_glob('/test/dir1/nonexistent*'),
116-
[])
117+
[])
117118
is_windows = sys.platform.startswith('win')
118119
matching_paths = example.get_glob('/test/dir1/dir*')
119120
if is_windows:
@@ -122,12 +123,12 @@ def test_get_globs(self):
122123
self.assertEqual(matching_paths, ['/test/dir1/dir2a', '/test/dir1/dir2b'])
123124

124125
def test_rm_tree(self):
125-
'''Test example.rm_tree()
126+
"""Test example.rm_tree()
126127
127128
`self.fs.CreateDirectory()` creates directories. However, you might
128129
prefer the familiar `os.makedirs()`, which also works fine on the fake
129130
file system.
130-
'''
131+
"""
131132
self.fs.CreateDirectory('/test/dir1/dir2a')
132133
# os.mkdirs() works, too.
133134
os.makedirs('/test/dir1/dir2b')
@@ -137,5 +138,6 @@ def test_rm_tree(self):
137138
example.rm_tree('/test/dir1')
138139
self.assertFalse(os.path.exists('/test/dir1'))
139140

141+
140142
if __name__ == "__main__":
141143
unittest.main()

fake_filesystem_glob_test.py

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import doctest
2020
import sys
21+
2122
if sys.version_info < (2, 7):
2223
import unittest2 as unittest
2324
else:
@@ -28,55 +29,54 @@
2829

2930

3031
class FakeGlobUnitTest(unittest.TestCase):
32+
def setUp(self):
33+
self.filesystem = fake_filesystem.FakeFilesystem(path_separator='/')
34+
self.glob = fake_filesystem_glob.FakeGlobModule(self.filesystem)
35+
directory = './xyzzy'
36+
self.filesystem.CreateDirectory(directory)
37+
self.filesystem.CreateDirectory('%s/subdir' % directory)
38+
self.filesystem.CreateDirectory('%s/subdir2' % directory)
39+
self.filesystem.CreateFile('%s/subfile' % directory)
40+
self.filesystem.CreateFile('[Temp]')
3141

32-
def setUp(self):
33-
self.filesystem = fake_filesystem.FakeFilesystem(path_separator='/')
34-
self.glob = fake_filesystem_glob.FakeGlobModule(self.filesystem)
35-
directory = './xyzzy'
36-
self.filesystem.CreateDirectory(directory)
37-
self.filesystem.CreateDirectory('%s/subdir' % directory)
38-
self.filesystem.CreateDirectory('%s/subdir2' % directory)
39-
self.filesystem.CreateFile('%s/subfile' % directory)
40-
self.filesystem.CreateFile('[Temp]')
41-
42-
def testGlobEmpty(self):
43-
self.assertEqual(self.glob.glob(''), [])
42+
def testGlobEmpty(self):
43+
self.assertEqual(self.glob.glob(''), [])
4444

45-
def testGlobStar(self):
46-
self.assertEqual(['/xyzzy/subdir', '/xyzzy/subdir2', '/xyzzy/subfile'],
47-
self.glob.glob('/xyzzy/*'))
45+
def testGlobStar(self):
46+
self.assertEqual(['/xyzzy/subdir', '/xyzzy/subdir2', '/xyzzy/subfile'],
47+
self.glob.glob('/xyzzy/*'))
4848

49-
def testGlobExact(self):
50-
self.assertEqual(['/xyzzy'], self.glob.glob('/xyzzy'))
51-
self.assertEqual(['/xyzzy/subfile'], self.glob.glob('/xyzzy/subfile'))
49+
def testGlobExact(self):
50+
self.assertEqual(['/xyzzy'], self.glob.glob('/xyzzy'))
51+
self.assertEqual(['/xyzzy/subfile'], self.glob.glob('/xyzzy/subfile'))
5252

53-
def testGlobQuestion(self):
54-
self.assertEqual(['/xyzzy/subdir', '/xyzzy/subdir2', '/xyzzy/subfile'],
55-
self.glob.glob('/x?zz?/*'))
53+
def testGlobQuestion(self):
54+
self.assertEqual(['/xyzzy/subdir', '/xyzzy/subdir2', '/xyzzy/subfile'],
55+
self.glob.glob('/x?zz?/*'))
5656

57-
def testGlobNoMagic(self):
58-
self.assertEqual(['/xyzzy'], self.glob.glob('/xyzzy'))
59-
self.assertEqual(['/xyzzy/subdir'], self.glob.glob('/xyzzy/subdir'))
57+
def testGlobNoMagic(self):
58+
self.assertEqual(['/xyzzy'], self.glob.glob('/xyzzy'))
59+
self.assertEqual(['/xyzzy/subdir'], self.glob.glob('/xyzzy/subdir'))
6060

61-
def testNonExistentPath(self):
62-
self.assertEqual([], self.glob.glob('nonexistent'))
61+
def testNonExistentPath(self):
62+
self.assertEqual([], self.glob.glob('nonexistent'))
6363

64-
def testDocTest(self):
65-
self.assertFalse(doctest.testmod(fake_filesystem_glob)[0])
64+
def testDocTest(self):
65+
self.assertFalse(doctest.testmod(fake_filesystem_glob)[0])
6666

67-
def testMagicDir(self):
68-
self.assertEqual(['/[Temp]'], self.glob.glob('/*emp*'))
67+
def testMagicDir(self):
68+
self.assertEqual(['/[Temp]'], self.glob.glob('/*emp*'))
6969

70-
def testRootGlob(self):
71-
self.assertEqual(['[Temp]', 'xyzzy'], self.glob.glob('*'))
70+
def testRootGlob(self):
71+
self.assertEqual(['[Temp]', 'xyzzy'], self.glob.glob('*'))
7272

73-
def testGlob1(self):
74-
self.assertEqual(['[Temp]'], self.glob.glob1('/', '*Tem*'))
73+
def testGlob1(self):
74+
self.assertEqual(['[Temp]'], self.glob.glob1('/', '*Tem*'))
7575

76-
def testHasMagic(self):
77-
self.assertTrue(self.glob.has_magic('['))
78-
self.assertFalse(self.glob.has_magic('a'))
76+
def testHasMagic(self):
77+
self.assertTrue(self.glob.has_magic('['))
78+
self.assertFalse(self.glob.has_magic('a'))
7979

8080

8181
if __name__ == '__main__':
82-
unittest.main()
82+
unittest.main()

0 commit comments

Comments
 (0)