Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SickRage-1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
SickRage-1
Commits
bc5d620f
Commit
bc5d620f
authored
9 years ago
by
labrys
Browse files
Options
Downloads
Plain Diff
Merge pull request #235 from labrys/lint-all_tests
Lint all_tests.py
parents
f5f58f9d
a14630be
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/all_tests.py
+49
-11
49 additions, 11 deletions
tests/all_tests.py
with
49 additions
and
11 deletions
tests/all_tests.py
+
49
−
11
View file @
bc5d620f
...
...
@@ -18,49 +18,83 @@
# You should have received a copy of the GNU General Public License
# along with SickRage. If not, see <http://www.gnu.org/licenses/>.
# pylint: disable=line-too-long
"""
Perform all tests in tests/
"""
import
fnmatch
import
os
import
sys
import
unittest
tests_dir
=
os
.
path
.
abspath
(
__file__
)[:
-
len
(
os
.
path
.
basename
(
__file__
))]
sys
.
path
.
insert
(
1
,
os
.
path
.
join
(
tests_dir
,
'
../lib
'
))
sys
.
path
.
insert
(
1
,
os
.
path
.
join
(
tests_dir
,
'
..
'
))
TESTS_DIR
=
os
.
path
.
abspath
(
__file__
)[:
-
len
(
os
.
path
.
basename
(
__file__
))]
sys
.
path
.
insert
(
1
,
os
.
path
.
join
(
TESTS_DIR
,
'
../lib
'
))
sys
.
path
.
insert
(
1
,
os
.
path
.
join
(
TESTS_DIR
,
'
..
'
))
class
AllTests
(
unittest
.
TestCase
):
"""
Performs all tests in tests directory.
Methods
setUp
test_all
_get_module_strings
_get_test_files
_get_test_suites
"""
# Block issue_submitter_tests to avoid issue tracker spam on every build
blacklist
=
[
tests_dir
+
'
all_tests.py
'
,
tests_dir
+
'
issue_submitter_tests.py
'
,
tests_dir
+
'
search_tests.py
'
]
blacklist
=
[
TESTS_DIR
+
'
all_tests.py
'
,
TESTS_DIR
+
'
issue_submitter_tests.py
'
,
TESTS_DIR
+
'
search_tests.py
'
]
def
setUp
(
self
):
"""
Get all tests
"""
self
.
test_file_strings
=
self
.
_get_test_files
()
self
.
module_strings
=
self
.
_get_module_strings
()
self
.
suites
=
self
.
_get_test_suites
()
self
.
test
S
uite
=
unittest
.
TestSuite
(
self
.
suites
)
self
.
test
_s
uite
=
unittest
.
TestSuite
(
self
.
suites
)
def
testAll
(
self
):
def
test_all
(
self
):
"""
Perform all tests
"""
print
"
====================
"
print
"
STARTING - ALL TESTS
"
print
"
====================
"
for
included_files
in
self
.
test_file_strings
:
print
"
-
"
+
included_files
[
len
(
tests_dir
):
-
3
]
print
"
-
"
+
included_files
[
len
(
TESTS_DIR
):
-
3
]
text_runner
=
unittest
.
TextTestRunner
().
run
(
self
.
test
S
uite
)
text_runner
=
unittest
.
TextTestRunner
().
run
(
self
.
test
_s
uite
)
if
not
text_runner
.
wasSuccessful
():
sys
.
exit
(
-
1
)
def
_get_module_strings
(
self
):
"""
Convert the file names into module names
:return: all module names
"""
modules
=
[]
for
file_string
in
self
.
test_file_strings
:
modules
.
append
(
file_string
[
len
(
tests_dir
):
len
(
file_string
)
-
3
].
replace
(
os
.
sep
,
'
.
'
))
modules
.
append
(
file_string
[
len
(
TESTS_DIR
):
len
(
file_string
)
-
3
].
replace
(
os
.
sep
,
'
.
'
))
return
modules
def
_get_test_files
(
self
):
"""
Get the name of all the tests in the tests directory
:return: all file names that match
"""
matches
=
[]
for
root
,
_
,
file_names
in
os
.
walk
(
tests_dir
):
for
root
,
_
,
file_names
in
os
.
walk
(
TESTS_DIR
):
for
filename
in
fnmatch
.
filter
(
file_names
,
'
*_tests.py
'
):
filename_with_path
=
os
.
path
.
join
(
root
,
filename
)
...
...
@@ -70,8 +104,12 @@ class AllTests(unittest.TestCase):
return
matches
def
_get_test_suites
(
self
):
return
[
unittest
.
defaultTestLoader
.
loadTestsFromName
(
file_string
)
for
file_string
in
self
.
module_strings
]
"""
Load all test suites
:return: all test suites from tests
"""
return
[
unittest
.
defaultTestLoader
.
loadTestsFromName
(
file_string
)
for
file_string
in
self
.
module_strings
]
if
__name__
==
"
__main__
"
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment