FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
learningPython/test/test_commit.py at master · EngineerLogbook/learningPython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
EngineerLogbook
/
learningPython
Public
Notifications
You must be signed in to change notification settings
Fork
11
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
learningPython
/
test
/
test_commit.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
51 lines (38 loc) · 1.78 KB
Breadcrumbs
learningPython
/
test
/
test_commit.py
Copy path
File metadata and controls
51 lines (38 loc) · 1.78 KB
Raw
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
()
Back
|
FazBrowse Home
|
New Git URL