python: Fix identification of runnable tests within decorated test classes (#29688)
Closes #29486 Release Notes: - python: Fixed identification of runnable test functions within decorated pytest classes
This commit is contained in:
parent
4d934f2884
commit
d03d8ccec1
1 changed files with 70 additions and 39 deletions
|
@ -55,6 +55,7 @@
|
|||
(#set! tag python-pytest-method)
|
||||
)
|
||||
|
||||
|
||||
; pytest classes
|
||||
(
|
||||
(module
|
||||
|
@ -66,6 +67,22 @@
|
|||
)
|
||||
)
|
||||
|
||||
|
||||
; decorated pytest classes
|
||||
(
|
||||
(module
|
||||
(decorated_definition
|
||||
(decorator)+ @_decorator
|
||||
definition: (class_definition
|
||||
name: (identifier) @run @_pytest_class_name
|
||||
(#match? @_pytest_class_name "^Test")
|
||||
)
|
||||
)
|
||||
(#set! tag python-pytest-class)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
; pytest class methods
|
||||
(
|
||||
(module
|
||||
|
@ -73,12 +90,19 @@
|
|||
name: (identifier) @_pytest_class_name
|
||||
(#match? @_pytest_class_name "^Test")
|
||||
body: (block
|
||||
[(decorated_definition
|
||||
(decorator)+ @_decorator
|
||||
definition: (function_definition
|
||||
name: (identifier) @run @_pytest_method_name
|
||||
(#match? @_pytest_method_name "^test_")
|
||||
)
|
||||
)
|
||||
(function_definition
|
||||
name: (identifier) @run @_pytest_method_name
|
||||
(#match? @_pytest_method_name "^test")
|
||||
) @_python-pytest-method
|
||||
(#set! tag python-pytest-method)
|
||||
)
|
||||
] @_python-pytest-method)
|
||||
(#set! tag python-pytest-method)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -86,22 +110,29 @@
|
|||
; decorated pytest class methods
|
||||
(
|
||||
(module
|
||||
(class_definition
|
||||
(decorated_definition
|
||||
(decorator)+ @_decorator
|
||||
definition: (class_definition
|
||||
name: (identifier) @_pytest_class_name
|
||||
(#match? @_pytest_class_name "^Test")
|
||||
body: (block
|
||||
(decorated_definition
|
||||
[(decorated_definition
|
||||
(decorator)+ @_decorator
|
||||
definition: (function_definition
|
||||
name: (identifier) @run @_pytest_method_name
|
||||
(#match? @_pytest_method_name "^test_")
|
||||
)
|
||||
)
|
||||
) @_python-pytest-method
|
||||
(function_definition
|
||||
name: (identifier) @run @_pytest_method_name
|
||||
(#match? @_pytest_method_name "^test")
|
||||
)
|
||||
] @_python-pytest-method)
|
||||
(#set! tag python-pytest-method)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; module main method
|
||||
(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue