Skip to content

Commit

Permalink
Testing: Remove unnecessary skip from test_get_interactive_backend
Browse files Browse the repository at this point in the history
Also, fix small linting and code issues
  • Loading branch information
ccordoba12 committed Aug 13, 2024
1 parent 0fe4b5c commit d05a433
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions spyder_kernels/console/tests/test_console_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1141,10 +1141,8 @@ def test_locals_globals_in_pdb(kernel):
@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")
reason="Doesn't work with pip packages"
)
def test_get_interactive_backend(backend):
"""
Test that we correctly get the interactive backend set in the kernel.
Expand All @@ -1158,14 +1156,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']
Expand Down Expand Up @@ -1240,7 +1241,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)
Expand Down Expand Up @@ -1371,8 +1372,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

Expand All @@ -1383,9 +1383,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

Expand Down

0 comments on commit d05a433

Please sign in to comment.