Skip to content

Commit

Permalink
Fix: Allow both '*_test.py' and '*test_.py' test module naming conven…
Browse files Browse the repository at this point in the history
…tion for nested tasks (#2155)

* Allow both '*_test.py' and '*test_.py' test module naming convention for nested tasks

Signed-off-by: Fabio Grätz <[email protected]>

* Adapt docstring

Signed-off-by: Fabio Grätz <[email protected]>

---------

Signed-off-by: Fabio Grätz <[email protected]>
Co-authored-by: Fabio Grätz <[email protected]>
  • Loading branch information
fg91 and Fabio Grätz authored Feb 5, 2024
1 parent f721eef commit 0878397
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions flytekit/core/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,17 @@ def foo_inner(*args, **kwargs):

def istestfunction(func) -> bool:
"""
Returns true if the function is defined in a test module. A test module has to have `test_` as the prefix.
False in all other cases
Return true if the function is defined in a test module.
A test module has to have `test_` as the prefix or `_test` as the suffix.
False in all other cases.
"""
mod = inspect.getmodule(func)
if mod:
mod_name = mod.__name__
if "." in mod_name:
mod_name = mod_name.split(".")[-1]
return mod_name.startswith("test_")
return mod_name.startswith("test_") or mod_name.endswith("_test")
return False


Expand Down

0 comments on commit 0878397

Please sign in to comment.