Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit dda1890

Browse files
committed
Add test class name check
1 parent 3451aef commit dda1890

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Diff for: script/validators/source_validator.py

+20
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,26 @@ def check_includes(file_path):
202202
return file_status
203203

204204

205+
def check_tests(file_path):
206+
"""Checks test source files for correct class and method naming."""
207+
# check class naming
208+
file_status = True
209+
line_num = 0
210+
with open(file_path, "r") as file:
211+
for line in file:
212+
line_num += 1
213+
if line.startswith('class '):
214+
class_name = line.split(' ')[1]
215+
if not class_name.endswith('Tests'):
216+
if file_status:
217+
LOG.info("Invalid class name in %s", file_path)
218+
file_status = False
219+
LOG.info("Line %s: %s", line_num, line.strip())
220+
if not file_status:
221+
LOG.info("Test class names should end with 'Tests' suffix.")
222+
return file_status
223+
# check method naming
224+
205225
VALIDATORS = [
206226
check_common_patterns,
207227
check_includes,

0 commit comments

Comments
 (0)