Skip to content

Commit 1305593

Browse files
cpuhrschfacebook-github-bot
authored andcommitted
[fbsync] Fix accept mechanism in tests (#3721)
Reviewed By: NicolasHug Differential Revision: D28169159 fbshipit-source-id: ebc5955e62c1f6184124ccd3725bc3ebcd3325ab
1 parent 323d7be commit 1305593

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

test/common_utils.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,6 @@ def set_rng_seed(seed):
4747
TEST_WITH_SLOW = os.getenv('PYTORCH_TEST_WITH_SLOW', '0') == '1'
4848

4949

50-
parser = argparse.ArgumentParser(add_help=False)
51-
parser.add_argument('--accept', action='store_true')
52-
args, remaining = parser.parse_known_args()
53-
if not ACCEPT:
54-
ACCEPT = args.accept
55-
for i, arg in enumerate(sys.argv):
56-
if arg == '--accept':
57-
del sys.argv[i]
58-
break
59-
60-
6150
class MapNestedTensorObjectImpl(object):
6251
def __init__(self, tensor_map_fn):
6352
self.tensor_map_fn = tensor_map_fn
@@ -119,8 +108,9 @@ def _get_expected_file(self, name=None):
119108
if not ACCEPT and not os.path.exists(expected_file):
120109
raise RuntimeError(
121110
f"No expect file exists for {os.path.basename(expected_file)} in {expected_file}; "
122-
"to accept the current output, run:\n"
123-
f"python {__main__.__file__} {munged_id} --accept")
111+
"to accept the current output, re-run the failing test after setting the EXPECTTEST_ACCEPT "
112+
"env variable. For example: EXPECTTEST_ACCEPT=1 pytest test/test_models.py -k alexnet"
113+
)
124114

125115
return expected_file
126116

0 commit comments

Comments
 (0)