From 85be11e60d768ca9ebeb7f4d01ae2e1786964a4c Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Mon, 22 Jul 2024 11:33:08 -0500 Subject: [PATCH] Testing: Remove unnecessary skips from test_get_interactive_backend Also, fix small linting and code issues --- .../console/tests/test_console_kernel.py | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/spyder_kernels/console/tests/test_console_kernel.py b/spyder_kernels/console/tests/test_console_kernel.py index 98df39e6..5f2ecb3a 100644 --- a/spyder_kernels/console/tests/test_console_kernel.py +++ b/spyder_kernels/console/tests/test_console_kernel.py @@ -278,7 +278,7 @@ def test_get_namespace_view(kernel): """ Test the namespace view of the kernel. """ - execute = asyncio.run(kernel.do_execute('a = 1', True)) + asyncio.run(kernel.do_execute('a = 1', True)) nsview = repr(kernel.get_namespace_view()) assert "'a':" in nsview @@ -294,7 +294,7 @@ def test_get_namespace_view_filter_on(kernel, filter_on): """ Test the namespace view of the kernel with filters on and off. """ - execute = asyncio.run(kernel.do_execute('a = 1', True)) + asyncio.run(kernel.do_execute('a = 1', True)) asyncio.run(kernel.do_execute('TestFilterOff = 1', True)) settings = kernel.namespace_view_settings @@ -986,7 +986,7 @@ def test_namespaces_in_pdb(kernel): Test namespaces in pdb """ # Define get_ipython for timeit - get_ipython = lambda: kernel.shell + get_ipython = lambda: kernel.shell # noqa kernel.shell.user_ns["test"] = 0 pdb_obj = SpyderPdb() pdb_obj.curframe = inspect.currentframe() @@ -1062,7 +1062,7 @@ def test_functions_with_locals_in_pdb_2(kernel): This is another regression test for spyder-ide/spyder-kernels#345 """ - baba = 1 + baba = 1 # noqa pdb_obj = SpyderPdb() pdb_obj.curframe = inspect.currentframe() pdb_obj.curframe_locals = pdb_obj.curframe.f_locals @@ -1099,7 +1099,7 @@ def test_locals_globals_in_pdb(kernel): """ Test thal locals and globals work properly in Pdb. """ - a = 1 + a = 1 # noqa pdb_obj = SpyderPdb() pdb_obj.curframe = inspect.currentframe() pdb_obj.curframe_locals = pdb_obj.curframe.f_locals @@ -1139,12 +1139,6 @@ def test_locals_globals_in_pdb(kernel): @flaky(max_runs=3) @pytest.mark.parametrize("backend", [None, 'inline', 'tk', 'qt']) -@pytest.mark.skipif( - os.environ.get('USE_CONDA') != 'true', - reason="Doesn't work with pip packages") -@pytest.mark.skipif( - sys.version_info[:2] < (3, 9), - reason="Too flaky in Python 3.8 and doesn't work in older versions") def test_get_interactive_backend(backend): """ Test that we correctly get the interactive backend set in the kernel. @@ -1158,14 +1152,17 @@ def test_get_interactive_backend(backend): # Set backend if backend is not None: client.execute_interactive( - "%matplotlib {}".format(backend), timeout=TIMEOUT) + "%matplotlib {}".format(backend), timeout=TIMEOUT + ) client.execute_interactive( - "import time; time.sleep(.1)", timeout=TIMEOUT) + "import time; time.sleep(.1)", timeout=TIMEOUT + ) # Get backend code = "backend = get_ipython().kernel.get_mpl_interactive_backend()" reply = client.execute_interactive( - code, user_expressions={'output': 'backend'}, timeout=TIMEOUT) + code, user_expressions={'output': 'backend'}, timeout=TIMEOUT + ) # Get value obtained through user_expressions user_expressions = reply['content']['user_expressions'] @@ -1240,7 +1237,7 @@ def test_debug_namespace(tmpdir): d.write('def func():\n bb = "hello"\n breakpoint()\nfunc()') # Run code file `d` - msg_id = client.execute("%runfile {}".format(repr(str(d)))) + client.execute("%runfile {}".format(repr(str(d)))) # make sure that 'bb' returns 'hello' client.get_stdin_msg(timeout=TIMEOUT) @@ -1371,8 +1368,7 @@ def test_non_strings_in_locals(kernel): This is a regression test for issue spyder-ide/spyder#19145 """ - execute = asyncio.run(kernel.do_execute('locals().update({1:2})', True)) - + asyncio.run(kernel.do_execute('locals().update({1:2})', True)) nsview = repr(kernel.get_namespace_view()) assert "1:" in nsview @@ -1383,9 +1379,7 @@ def test_django_settings(kernel): This is a regression test for issue spyder-ide/spyder#19516 """ - execute = asyncio.run(kernel.do_execute( - 'from django.conf import settings', True)) - + asyncio.run(kernel.do_execute('from django.conf import settings', True)) nsview = repr(kernel.get_namespace_view()) assert "'settings':" in nsview