mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
Add __main__ guards to fx tests (#154715)
This PR is part of a series attempting to re-submit #134592 as smaller PRs. In fx tests: - Add and use a common raise_on_run_directly method for when a user runs a test file directly which should not be run this way. Print the file which the user should have run. - Raise a RuntimeError on tests which have been disabled (not run) - Remove any remaining uses of "unittest.main()"" Pull Request resolved: https://github.com/pytorch/pytorch/pull/154715 Approved by: https://github.com/Skylion007
This commit is contained in:
committed by
PyTorch MergeBot
parent
cf9cad31df
commit
c8d44a2296
@ -902,6 +902,11 @@ def prof_callable(callable, *args, **kwargs):
|
||||
|
||||
return callable(*args, **kwargs)
|
||||
|
||||
def raise_on_run_directly(file_to_call):
|
||||
raise RuntimeError("This test file is not meant to be run directly, "
|
||||
f"use:\n\n\tpython {file_to_call} TESTNAME\n\n"
|
||||
"instead.")
|
||||
|
||||
def prof_func_call(*args, **kwargs):
|
||||
return prof_callable(func_call, *args, **kwargs)
|
||||
|
||||
|
Reference in New Issue
Block a user