Unverified Commit 283c7907 authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

Fix accept mechanism in tests (#3721)

parent 08fa7d6b
...@@ -47,17 +47,6 @@ ACCEPT = os.getenv('EXPECTTEST_ACCEPT') ...@@ -47,17 +47,6 @@ ACCEPT = os.getenv('EXPECTTEST_ACCEPT')
TEST_WITH_SLOW = os.getenv('PYTORCH_TEST_WITH_SLOW', '0') == '1' TEST_WITH_SLOW = os.getenv('PYTORCH_TEST_WITH_SLOW', '0') == '1'
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--accept', action='store_true')
args, remaining = parser.parse_known_args()
if not ACCEPT:
ACCEPT = args.accept
for i, arg in enumerate(sys.argv):
if arg == '--accept':
del sys.argv[i]
break
class MapNestedTensorObjectImpl(object): class MapNestedTensorObjectImpl(object):
def __init__(self, tensor_map_fn): def __init__(self, tensor_map_fn):
self.tensor_map_fn = tensor_map_fn self.tensor_map_fn = tensor_map_fn
...@@ -119,8 +108,9 @@ class TestCase(unittest.TestCase): ...@@ -119,8 +108,9 @@ class TestCase(unittest.TestCase):
if not ACCEPT and not os.path.exists(expected_file): if not ACCEPT and not os.path.exists(expected_file):
raise RuntimeError( raise RuntimeError(
f"No expect file exists for {os.path.basename(expected_file)} in {expected_file}; " f"No expect file exists for {os.path.basename(expected_file)} in {expected_file}; "
"to accept the current output, run:\n" "to accept the current output, re-run the failing test after setting the EXPECTTEST_ACCEPT "
f"python {__main__.__file__} {munged_id} --accept") "env variable. For example: EXPECTTEST_ACCEPT=1 pytest test/test_models.py -k alexnet"
)
return expected_file return expected_file
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment