Skip to content

Commit e1013c5

Browse files
committed
Add autouse fixture to mock webbrowser.open in tests
Prevents browsers from opening during test runs by automatically mocking webbrowser.open for all tests. Also updates the JSONL snapshot to match current output. https://gistpreview.github.io/?1671b49de273d80280ab2ceab690db8c/index.html
1 parent 77512e5 commit e1013c5

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

tests/__snapshots__/test_generate_html/TestParseSessionFile.test_jsonl_generates_html.html

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,29 @@
126126
<body>
127127
<div class="container">
128128
<h1>Claude Code transcript</h1>
129-
<div class="pagination">
129+
130+
131+
<div class="pagination">
130132
<span class="current">Index</span>
131-
<span class="disabled"> Prev</span>
133+
<span class="disabled">&larr; Prev</span>
132134
<a href="page-001.html">1</a>
133-
<a href="page-001.html">Next </a>
135+
<a href="page-001.html">Next &rarr;</a>
134136
</div>
137+
135138
<p style="color: var(--text-muted); margin-bottom: 24px;">2 prompts · 7 messages · 2 tool calls · 1 commits · 1 pages</p>
136-
<div class="index-item"><a href="page-001.html#msg-2025-12-24T10-00-00-000Z"><div class="index-item-header"><span class="index-item-number">#1</span><time datetime="2025-12-24T10:00:00.000Z" data-timestamp="2025-12-24T10:00:00.000Z">2025-12-24T10:00:00.000Z</time></div><div class="index-item-content"><p>Create a hello world function</p></div></a><div class="index-item-stats"><span>1 write · 1 bash</span></div></div><div class="index-commit"><div class="index-commit-header"><span class="index-commit-hash">abc1234</span><time datetime="2025-12-24T10:00:20.000Z" data-timestamp="2025-12-24T10:00:20.000Z">2025-12-24T10:00:20.000Z</time></div><div class="index-commit-msg">Add hello function</div></div><div class="index-item"><a href="page-001.html#msg-2025-12-24T10-01-00-000Z"><div class="index-item-header"><span class="index-item-number">#2</span><time datetime="2025-12-24T10:01:00.000Z" data-timestamp="2025-12-24T10:01:00.000Z">2025-12-24T10:01:00.000Z</time></div><div class="index-item-content"><p>Now add a goodbye function</p></div></a></div>
137-
<div class="pagination">
139+
140+
<div class="index-item"><a href="page-001.html#msg-2025-12-24T10-00-00-000Z"><div class="index-item-header"><span class="index-item-number">#1</span><time datetime="2025-12-24T10:00:00.000Z" data-timestamp="2025-12-24T10:00:00.000Z">2025-12-24T10:00:00.000Z</time></div><div class="index-item-content"><p>Create a hello world function</p></div></a><div class="index-item-stats"><span>1 write · 1 bash</span>
141+
</div></div><div class="index-commit"><div class="index-commit-header"><span class="index-commit-hash">abc1234</span><time datetime="2025-12-24T10:00:20.000Z" data-timestamp="2025-12-24T10:00:20.000Z">2025-12-24T10:00:20.000Z</time></div><div class="index-commit-msg">Add hello function</div></div>
142+
<div class="index-item"><a href="page-001.html#msg-2025-12-24T10-01-00-000Z"><div class="index-item-header"><span class="index-item-number">#2</span><time datetime="2025-12-24T10:01:00.000Z" data-timestamp="2025-12-24T10:01:00.000Z">2025-12-24T10:01:00.000Z</time></div><div class="index-item-content"><p>Now add a goodbye function</p></div></a></div>
143+
144+
145+
<div class="pagination">
138146
<span class="current">Index</span>
139-
<span class="disabled"> Prev</span>
147+
<span class="disabled">&larr; Prev</span>
140148
<a href="page-001.html">1</a>
141-
<a href="page-001.html">Next </a>
149+
<a href="page-001.html">Next &rarr;</a>
142150
</div>
151+
143152
</div>
144153
<script>
145154
document.querySelectorAll('time[data-timestamp]').forEach(function(el) {

tests/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""Pytest configuration and fixtures for claude-code-publish tests."""
2+
3+
import pytest
4+
5+
6+
@pytest.fixture(autouse=True)
7+
def mock_webbrowser_open(monkeypatch):
8+
"""Automatically mock webbrowser.open to prevent browsers opening during tests."""
9+
opened_urls = []
10+
11+
def mock_open(url):
12+
opened_urls.append(url)
13+
return True
14+
15+
monkeypatch.setattr("claude_code_publish.webbrowser.open", mock_open)
16+
return opened_urls

0 commit comments

Comments
 (0)