Exemple #1
0
class TestGcc(unittest.TestCase):
    def setUp(self):
        self.filename_c = 'foobar.c'
        self.compiler = Gcc(self.filename_c)

    @patch('universal.compiler.language.gcc.perform_system_command')
    def test_compile(self, mock_sys_cmd):
        self.compiler.compile()
        mock_sys_cmd.assert_called_once_with(AnyStringContaining('gcc'))

    @patch('os.path.exists')
    @patch('universal.compiler.language.gcc.perform_system_command')
    def test_run_output_when_no_input_file_available(self, mock_sys_cmd,
                                                     mock_path_exists):
        mock_path_exists.return_value = False

        self.compiler.run()

        mock_sys_cmd.assert_called_once_with(AnyStringContaining('foobar.out'))

    @patch('os.path.exists')
    @patch('universal.compiler.language.gcc.perform_system_command')
    def test_run_output_when_input_file_available(self, mock_sys_cmd,
                                                  mock_path_exists):
        mock_path_exists.return_value = True

        self.compiler.run()

        mock_sys_cmd.assert_called_once_with(
            AnyStringContaining('foobar.input'))
class TestGcc(unittest.TestCase):
    def setUp(self):
        self.filename_c = 'foobar.c'
        self.compiler = Gcc(self.filename_c)

    @patch('universal.compiler.language.gcc.perform_system_command')
    def test_compile(self, mock_sys_cmd):
        self.compiler.compile()
        mock_sys_cmd.assert_called_once_with(AnyStringContaining('gcc'))


    @patch('os.path.exists')
    @patch('universal.compiler.language.gcc.perform_system_command')
    def test_run_output_when_no_input_file_available(self, mock_sys_cmd, mock_path_exists):
        mock_path_exists.return_value = False

        self.compiler.run()

        mock_sys_cmd.assert_called_once_with(AnyStringContaining('foobar.out'))

    @patch('os.path.exists')
    @patch('universal.compiler.language.gcc.perform_system_command')
    def test_run_output_when_input_file_available(self, mock_sys_cmd, mock_path_exists):
        mock_path_exists.return_value = True

        self.compiler.run()

        mock_sys_cmd.assert_called_once_with(AnyStringContaining('foobar.input'))
Exemple #3
0
 def setUp(self):
     self.filename_c = 'foobar.c'
     self.compiler = Gcc(self.filename_c)
 def setUp(self):
     self.filename_c = 'foobar.c'
     self.compiler = Gcc(self.filename_c)