Skip to content

Commit

Permalink
Fix extras tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evhub committed Nov 27, 2023
1 parent 055b1e5 commit 9b0ee55
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions coconut/tests/src/extras.coco
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ from coconut.convenience import (
warm_up,
)

if IPY:
if PY35:
import asyncio
from coconut.icoconut import CoconutKernel # type: ignore
from jupyter_client.session import Session
else:
CoconutKernel = None # type: ignore
Session = object # type: ignore


def assert_raises(c, Exc, not_Exc=None, err_has=None):
"""Test whether callable c raises an exception of type Exc."""
Expand Down Expand Up @@ -83,15 +74,6 @@ def unwrap_future(event_loop, maybe_future):
return maybe_future


class FakeSession(Session):
if TYPE_CHECKING:
captured_messages: list[tuple] = []
else:
captured_messages: list = []
def send(self, stream, msg_or_type, content, *args, **kwargs):
self.captured_messages.append((msg_or_type, content))


def test_setup_none() -> bool:
setup(line_numbers=False)

Expand Down Expand Up @@ -468,6 +450,20 @@ class F:


def test_kernel() -> bool:
# hide imports so as to not enable incremental parsing until we want to
if PY35:
import asyncio
from coconut.icoconut import CoconutKernel # type: ignore
from jupyter_client.session import Session

class FakeSession(Session):
if TYPE_CHECKING:
captured_messages: list[tuple] = []
else:
captured_messages: list = []
def send(self, stream, msg_or_type, content, *args, **kwargs):
self.captured_messages.append((msg_or_type, content))

if PY35:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
Expand Down Expand Up @@ -640,15 +636,16 @@ def test_extras() -> bool:
print(".", end="")
if not PYPY and PY36:
assert test_pandas() is True # .
print(".", end="")
if CoconutKernel is not None:
assert test_kernel() is True # ..
print(".") # newline bc we print stuff after this
assert test_setup_none() is True
assert test_setup_none() is True # ..
print(".") # ditto
assert test_convenience() is True
assert test_convenience() is True # ...
# everything after here uses incremental parsing, so it must come last
print(".", end="")
assert test_incremental() is True # must come last
assert test_incremental() is True # ....
if IPY:
print(".", end="")
assert test_kernel() is True # .....
return True


Expand Down

0 comments on commit 9b0ee55

Please sign in to comment.