Skip to content

Some test modules are using unittest.main() instead of common_utils.run_tests() #50448

@xwang233

Description

@xwang233

🚀 Feature

Some test modules are using unittest.main() instead of torch.testing._internal.common_utils.run_tests(). Thus, the arg parser in common_utils are not running for these tests, which makes the whole test suite somewhat inconsistent.

parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--subprocess', action='store_true',
help='whether to run each test in a subprocess')
parser.add_argument('--seed', type=int, default=1234)
parser.add_argument('--accept', action='store_true')
parser.add_argument('--jit_executor', type=str)
parser.add_argument('--repeat', type=int, default=1)
parser.add_argument('--test_bailouts', action='store_true')
parser.add_argument('--save-xml', nargs='?', type=str,
const=_get_test_report_path(),
default=_get_test_report_path() if bool(os.environ.get('IN_CI')) else None)
parser.add_argument('--discover-tests', action='store_true')
parser.add_argument('--log-suffix', type=str, default="")
parser.add_argument('--run-parallel', type=int, default=1)

test_expecttest
test_mobile_optimizer
test_show_pickle
test_namedtuple_return_api 
test_jit_disabled 
test_overrides 
test_tensorexpr 
test_package 

We encountered this in a problem while running tests

python test/run_test.py --verbose -- --save-xml -v

--save-xml should be passed to each test module, but some test modules not using common_utils.run_tests() don't have these parser and will just throw an error: unrecognized arguments: --save-xml

cc @mruberry @VitalyFedyunin @walterddr @ptrblck

Metadata

Metadata

Assignees

Labels

better-engineeringRelatively self-contained tasks for better engineering contributorsenhancementNot as big of a feature, but technically not a bug. Should be easy to fixmodule: testingIssues related to the torch.testing module (not tests)module: testsIssues related to tests (not the torch.testing module)triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions