Exemplo n.º 1
0
    def test_should_write_utf8_command_to_named_pipe(self, mock_time, mock_open):
        mock_open.return_value = MagicMock(spec=file)
        mock_time.return_value = '123'

        perform_command(u'FOO;bär', '/path/to/commandfile.cmd')

        mock_file = mock_open.return_value.__enter__.return_value
        mock_file.write.assert_called_with(b'[123] FOO;b\xc3\xa4r\n')
Exemplo n.º 2
0
    def test_should_write_command_in_correct_syntax_to_named_pipe(self, mock_time, mock_open):
        mock_open.return_value = MagicMock(spec=file)
        mock_time.return_value = '123'

        perform_command('FOO;bar', '/path/to/commandfile.cmd')

        self.assertEqual(mock_open.call_args, call('/path/to/commandfile.cmd', 'w'))
        mock_file = mock_open.return_value.__enter__.return_value
        mock_file.write.assert_called_with(b'[123] FOO;bar\n')