Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize the use of QRegExp to use QRegularExpression #22259

Closed
wants to merge 1 commit into from

Conversation

hmaarrfk
Copy link
Contributor

@hmaarrfk hmaarrfk commented Jul 16, 2024

Apparently this was available since 5.0

TODO: read this to see if there is any incompatibility: https://doc.qt.io/qt-6/qregexp.html

Description of Changes

  • Wrote at least one-line docstrings (for any new functions)
  • Added unit test(s) covering the changes (if testable)
  • Included a screenshot or animation (if affecting the UI, see Licecap)

Just trying to help test against Qt6

Issue(s) Resolved

Fixes #

Affirmation

By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.

I certify the above statement is true and correct:

Mark Harfouche hmaarrfk

@pep8speaks
Copy link

pep8speaks commented Jul 16, 2024

Hello @hmaarrfk! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-07-16 00:20:27 UTC

Apparently this was available since 5.0

TODO: read this to see if there is any incompatibility:
https://doc.qt.io/qt-6/qregexp.html
@hmaarrfk hmaarrfk force-pushed the modernize_qregexp branch from 27aec90 to 322b611 Compare July 16, 2024 00:20
@hmaarrfk hmaarrfk marked this pull request as ready for review July 16, 2024 00:20
@hmaarrfk
Copy link
Contributor Author

I don't really understand where these are being used. I'm counting on the tests.

@hmaarrfk
Copy link
Contributor Author

I am continuously impressed at the level of your tests:

=================================== FAILURES ===================================
__________________________________ test_leaks __________________________________

main_window = <spyder.app.mainwindow.MainWindow object at 0x7f504be00160>
qtbot = <pytestqt.qtbot.QtBot object at 0x7f504bdf4d30>

    @pytest.mark.use_introspection
    @pytest.mark.skipif(os.name == 'nt', reason="Fails on Windows")
    def test_leaks(main_window, qtbot):
        """
        Test leaks in mainwindow when closing a file or a console.
    
        Many other ways of leaking exist but are not covered here.
        """
        # Wait until the window is fully up
        shell = main_window.ipyconsole.get_current_shellwidget()
        qtbot.waitUntil(
            lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT)
    
        # Count initial objects
        # Only one of each should be present, but because of many leaks,
        # this is most likely not the case. Here only closing is tested
        shell.wait_all_shutdown()
        gc.collect()
        objects = gc.get_objects()
        n_code_editor_init = 0
        for o in objects:
            if type(o).__name__ == "CodeEditor":
                n_code_editor_init += 1
        n_shell_init = 0
        for o in objects:
            if type(o).__name__ == "ShellWidget":
                n_shell_init += 1
        del objects
    
        # Open a second file and console
        main_window.editor.new()
        main_window.ipyconsole.create_new_client()
        # Do something interesting in the new window
        code_editor = main_window.editor.get_focus_widget()
        # Show an error in the editor
        code_editor.set_text("aaa")
        del code_editor
    
        shell = main_window.ipyconsole.get_current_shellwidget()
        qtbot.waitUntil(
            lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT)
        with qtbot.waitSignal(shell.executed):
            shell.execute("%debug print()")
    
        # Close all files and consoles
        main_window.editor.close_all_files()
        main_window.ipyconsole.restart()
    
        # Wait until the shells are closed
        shell = main_window.ipyconsole.get_current_shellwidget()
        shell.wait_all_shutdown()
        # Count final objects
        gc.collect()
        objects = gc.get_objects()
        n_code_editor = 0
        for o in objects:
            if type(o).__name__ == "CodeEditor":
                n_code_editor += 1
        n_shell = 0
        for o in objects:
            if type(o).__name__ == "ShellWidget":
                n_shell += 1
    
        # Make sure no new objects have been created
        assert n_shell <= n_shell_init
>       assert n_code_editor <= n_code_editor_init
E       assert 2 <= 1

/home/runner/work/spyder/spyder/spyder/app/tests/test_mainwindow.py:178: AssertionError

i wonder what changes I made that would trigger this...

@hmaarrfk hmaarrfk marked this pull request as draft July 16, 2024 01:18
@hmaarrfk
Copy link
Contributor Author

hmm, this is already done in Spyder 6.

@hmaarrfk hmaarrfk closed this Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants