Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
51 lines (38 loc) · 1.78 KB

File metadata and controls

51 lines (38 loc) · 1.78 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import unittest # for actual testing
import os
import pathlib # for traversing the directories
class testFileStructure(unittest.TestCase):
def setUp(self):
# Find and set the path to the base of the repository
self.root_folder = os.path.dirname(
os.path.dirname(os.path.abspath(__file__)))
# Generate a list of all directories in the repo
self.files = []
self.directories = []
for (dirpath, dirnames, filenames) in os.walk(self.root_folder):
self.files.extend((filenames))
self.directories.extend((dirnames))
# In order to only list files in the root folder
break
def test_directorystructure(self):
for filz in self.files:
# no files with .py extensions should be in the root of the directory
self.assertNotEqual(pathlib.Path(
filz).suffix, ".py", f"Python files are not allowed in the root of the project")
def test_personal_folders(self):
for dirz in self.directories:
if dirz == "test" or dirz[0] == ".":
continue
# There should be only one file inside each folder
self.assertEqual(len(os.listdir(
dirz)), 1, f"Only one file is allowed inside each folder. Offending folder : {dirz}")
def test_extensions_infolders(self):
for dirz in self.directories:
if dirz == "test" or dirz[0] == ".":
continue
for filzs in os.listdir(dirz):
# There should be only one file inside each folder
self.assertEqual(pathlib.Path(
filzs).suffix, ".py", f"Only .py files are allowed in the subfolders. Offending folder : {dirz}")
if __name__ == "__main__":
unittest.main()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.