Skip to content

Commit f84e8d7

Browse files
Nathan SpragueNathan Sprague
authored andcommitted
allow command line arguments for tested scripts.
1 parent 1aa8028 commit f84e8d7

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

jmu_gradescope_utils/jmu_test_case.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ class _JmuTestCase(unittest.TestCase):
8686
module_count = 0
8787

8888
def assertScriptOutputEqual(self, filename, string_in, expected,
89-
variables=None, msg=None, processor=None):
89+
variables=None, args="", msg=None,
90+
processor=None):
9091
tmpdir = None
9192
try:
9293
tmpdir, new_file_name = utils.replace_variables(filename,
@@ -99,8 +100,10 @@ def assertScriptOutputEqual(self, filename, string_in, expected,
99100
# Replace the original submission in source:
100101
shutil.copy(new_file_name, utils.full_source_path(filename))
101102

102-
proc = subprocess.Popen(['python3',
103-
utils.full_source_path(filename)],
103+
command = ['python3', utils.full_source_path(filename)]
104+
command.extend(args.split())
105+
106+
proc = subprocess.Popen(command,
104107
stdin=subprocess.PIPE,
105108
stdout=subprocess.PIPE,
106109
stderr=subprocess.PIPE)
@@ -119,6 +122,8 @@ def assertScriptOutputEqual(self, filename, string_in, expected,
119122

120123
show_in = string_in.encode('unicode_escape').decode()
121124
message = "Input was: '{}'".format(show_in)
125+
if len(args) > 0:
126+
message += "\nCommand line arguments: {}".format(args)
122127
if msg is not None:
123128
message += "\n" + msg
124129

0 commit comments

Comments
 (0)