Skip to content

Add end-to-end test for a Jupyter REPL session - #106

Merged
jhidding merged 2 commits into
mainfrom
test/repl-end-to-end
Nov 15, 2026
Merged

jhidding merged 2 commits into
mainfrom
test/repl-end-to-end

Conversation

@jhidding

@jhidding jhidding commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an end-to-end test of a REPL session with the Jupyter backend.

The input, test/data/repl-jupyter/primes.md, is a stand-alone document with no entangled.toml. Its YAML header turns on the repl hook and sets Python to use the Jupyter backend. The document tangles a primes.py module and then uses it in a session with three commands: one with a result, one that prints to stdout, and one with a Markdown result.

The test (test/integration/test_repl_jupyter.py):

  1. tangles the document and checks that primes.py was written;
  2. runs the session in a python3 Jupyter kernel;
  3. weaves with -f repl;
  4. checks that the result matches test/data/repl-jupyter/expected.md exactly.

Only primes.md is copied into the working directory. Without an entangled.toml, Entangled reads every *.md file, and that would include expected.md.

The test is skipped when ipykernel isn't installed. CI installs it, so it runs on all three platforms.

Fix: stale session output

On Windows CI an existing test failed intermittently. The repl filter cached decoded session output keyed on (path, mtime_ns), and a file rewritten in quick succession can keep the same mtime. The cache is now keyed on the file contents. A regression test reproduces the problem on any OS by resetting the mtime after a rewrite.

🤖 Generated with Claude Code

jhidding and others added 2 commits November 15, 2026 21:17
A stand-alone Markdown file, configured through its YAML header, tangles
a module and uses it in a Jupyter session. The test tangles, runs the
session, weaves with the `repl` filter and compares against expected
Markdown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
File systems with coarse timestamps (seen on Windows CI) can give a
rewritten session output file the same mtime, so the `repl` filter
used stale output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jhidding
jhidding merged commit 82753c6 into main Nov 15, 2026
9 checks passed
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.

1 participant