diff --git a/armi/physics/tests/test_executers.py b/armi/physics/tests/test_executers.py index a918a6152..e4e9fefad 100644 --- a/armi/physics/tests/test_executers.py +++ b/armi/physics/tests/test_executers.py @@ -113,10 +113,17 @@ def test_runExternalExecutable(self): """ filePath = "test_runExternalExecutable.py" outFile = "tmp.txt" + label = "printExtraStuff" - class TestSillyExecuter(executers.Executer): + class MockExecutionOptions(executers.ExecutionOptions): + pass + + class MockExecuter(executers.Executer): def run(self, args): - subprocess.run(["python", filePath, args]) + if self.options.label == label: + subprocess.run(["python", filePath, "extra stuff"]) + else: + subprocess.run(["python", filePath, args]) with directoryChangers.TemporaryDirectoryChanger(): # build a mock external program (a little Python script) @@ -126,7 +133,8 @@ def run(self, args): self.assertFalse(os.path.exists(outFile)) # set up an executer for our little test program - exe = TestSillyExecuter(None, None) + opts = MockExecutionOptions() + exe = MockExecuter(opts, None) exe.run("") # make sure the output file exists now @@ -141,6 +149,12 @@ def run(self, args): newTxt = open(outFile, "r").read() self.assertIn(testString, newTxt) + # now prove the options object can affect the execution + exe.options.label = label + exe.run("") + newerTxt = open(outFile, "r").read() + self.assertIn("extra stuff", newerTxt) + @staticmethod def __makeALittleTestProgram(filePath, outFile): """Helper method to write a tiny Python script.