class TheSimulatedShellShould(TestCase): def setUp(self): self._working_directory = "./" self._log = BytesIO() self._shell = SimulatedShell(self._log, self._working_directory) @property def log(self): return self._log.getvalue().decode() def test_not_run_any_command(self): self._shell.execute("echo Hello World!") expected_log = ( "\n" "camp@bash:./$ echo Hello World!\n" ">>> This command was only simulated and was not sent to the shell.\n" ) self.assertEquals(expected_log, self.log) def test_provides_nothing_as_file_content(self): with self._shell.open("a_file_that_does_not_exists", "r") as content: self.assertEquals("", content.read()) def test_find_no_files(self): temp_directory = gettempdir() reports = self._shell.find_all_files(".xml", temp_directory) self.assertEquals([], reports)
def setUp(self): self._listener = MagicMock(ExecutorListener) self._tested = Component(name="Foo", test_settings=TestSettings( "green tests", "junit", "./", ".xml")) self._log = BytesIO() self._engine = Engine(self._tested, SimulatedShell(self._log, "."), self._listener) self._configurations = [("config_1", "useless"), ("config_2", "useless")]
def _select_shell(self, arguments, log_file): shell = Shell(log_file, ".", self._ui) if arguments.is_simulated: shell = SimulatedShell(log_file, ".", self._ui) return shell
def setUp(self): self._working_directory = "./" self._log = BytesIO() self._shell = SimulatedShell(self._log, self._working_directory)