Exemple #1
0
def test_EditorPane_init():
    """
    Ensure everything is set and configured given a path and text passed into
    a new instance of the EditorPane.
    """
    mock_text = mock.MagicMock(return_value=None)
    mock_modified = mock.MagicMock(return_value=None)
    mock_configure = mock.MagicMock(return_value=None)
    with mock.patch('mu.interface.editor.EditorPane.setText', mock_text), \
            mock.patch('mu.interface.editor.EditorPane.setModified',
                       mock_modified), \
            mock.patch('mu.interface.editor.EditorPane.configure',
                       mock_configure):
        path = '/foo/bar.py'
        text = 'print("Hello, World!")'
        editor = mu.interface.editor.EditorPane(path, text, '\r\n')
        mock_text.assert_called_once_with(text)
        mock_modified.assert_called_once_with(False)
        mock_configure.assert_called_once_with()
        assert editor.isUtf8()
        assert editor.newline == '\r\n'
Exemple #2
0
def test_EditorPane_init():
    """
    Ensure everything is set and configured given a path and text passed into
    a new instance of the EditorPane.
    """
    mock_text = mock.MagicMock(return_value=None)
    mock_modified = mock.MagicMock(return_value=None)
    mock_configure = mock.MagicMock(return_value=None)
    with mock.patch('mu.interface.editor.EditorPane.setText', mock_text), \
            mock.patch('mu.interface.editor.EditorPane.setModified',
                       mock_modified), \
            mock.patch('mu.interface.editor.EditorPane.configure',
                       mock_configure):
        path = '/foo/bar.py'
        text = 'print("Hello, World!")'
        editor = mu.interface.editor.EditorPane(path, text, '\r\n')
        mock_text.assert_called_once_with(text)
        mock_modified.assert_called_once_with(False)
        mock_configure.assert_called_once_with()
        assert editor.isUtf8()
        assert editor.newline == '\r\n'
Exemple #3
0
def test_EditorPane_init_css():
    """
    Ensure everything is set and configured given a path and text passed into
    a new instance of the EditorPane. CSS file.
    """
    mock_text = mock.MagicMock(return_value=None)
    mock_modified = mock.MagicMock(return_value=None)
    mock_configure = mock.MagicMock(return_value=None)
    with mock.patch('mu.interface.editor.EditorPane.setText', mock_text), \
            mock.patch('mu.interface.editor.EditorPane.setModified',
                       mock_modified), \
            mock.patch('mu.interface.editor.EditorPane.configure',
                       mock_configure):
        path = '/foo/bar.css'
        text = 'h1 { color: red; }'
        editor = mu.interface.editor.EditorPane(path, text, '\r\n')
        mock_text.assert_called_once_with(text)
        mock_modified.assert_called_once_with(False)
        mock_configure.assert_called_once_with()
        assert editor.isUtf8()
        assert editor.newline == '\r\n'
        assert isinstance(editor.lexer, mu.interface.editor.QsciLexerCSS)
Exemple #4
0
def test_EditorPane_init_html():
    """
    Ensure everything is set and configured given a path and text passed into
    a new instance of the EditorPane. HTML file.
    """
    mock_text = mock.MagicMock(return_value=None)
    mock_modified = mock.MagicMock(return_value=None)
    mock_configure = mock.MagicMock(return_value=None)
    with mock.patch("mu.interface.editor.EditorPane.setText",
                    mock_text), mock.patch(
                        "mu.interface.editor.EditorPane.setModified",
                        mock_modified), mock.patch(
                            "mu.interface.editor.EditorPane.configure",
                            mock_configure):
        path = "/foo/bar.html"
        text = "<html></html>"
        editor = mu.interface.editor.EditorPane(path, text, "\r\n")
        mock_text.assert_called_once_with(text)
        mock_modified.assert_called_once_with(False)
        mock_configure.assert_called_once_with()
        assert editor.isUtf8()
        assert editor.newline == "\r\n"
        assert isinstance(editor.lexer, mu.interface.editor.QsciLexerHTML)
Exemple #5
0
def test_EditorPane_init_python(qtapp):
    """
    Ensure everything is set and configured given a path and text passed into
    a new instance of the EditorPane. Python file.
    """
    mock_text = mock.MagicMock(return_value=None)
    mock_modified = mock.MagicMock(return_value=None)
    mock_configure = mock.MagicMock(return_value=None)
    with mock.patch("mu.interface.editor.EditorPane.setText",
                    mock_text), mock.patch(
                        "mu.interface.editor.EditorPane.setModified",
                        mock_modified), mock.patch(
                            "mu.interface.editor.EditorPane.configure",
                            mock_configure):
        path = "/foo/bar.py"
        text = 'print("Hello, World!")'
        editor = mu.interface.editor.EditorPane(path, text, "\r\n")
        mock_text.assert_called_once_with(text)
        mock_modified.assert_called_once_with(False)
        mock_configure.assert_called_once_with()
        assert editor.isUtf8()
        assert editor.newline == "\r\n"
        assert isinstance(editor.lexer, mu.interface.editor.PythonLexer)