Skip to content

Autonomous AI sales agent powered by Claude Code or Codex. Finds prospects, writes cold emails, sends campaigns, handles replies, books meetings. No API keys needed — runs on your Claude or Codex subscriptions.

test: close SQLite connections before temporary database cleanup

Ethan+16e450bf5657
diff --git a/tests/test_collectors_profile.py b/tests/test_collectors_profile.py
index 99f3d1d..8aab757 100644
--- a/tests/test_collectors_profile.py
+++ b/tests/test_collectors_profile.py
@@ -1,6 +1,7 @@
"""Tests for the free PROFILE collector and the observation model."""
import os
+from contextlib import closing
import tempfile
import pytest
@@ -221,7 +222,7 @@ async def test_profile_upgrades_a_name_the_domain_does_not_back(state, monkeypat
{"id": keep, "name": "Birch Management", "domain": "birchmgt.com"},
{"id": derived, "name": "Grow With Us", "domain": "growwithus.us"}])
import sqlite3
- with sqlite3.connect(state.db_path) as db:
+ with closing(sqlite3.connect(state.db_path)) as db:
names = dict(db.execute("SELECT domain, name FROM companies"))
assert names["managementharbor.com"] == "Management Harbor"
assert names["birchmgt.com"] == "Birch Management" # already right: untouched
@@ -257,7 +258,7 @@ async def test_profile_repairs_weak_names_and_retains_brands(
async with ProfileCollector(state, set()) as c:
await c.run([{"id": cid, "name": current, "domain": domain}])
import sqlite3
- with sqlite3.connect(state.db_path) as db:
+ with closing(sqlite3.connect(state.db_path)) as db:
assert db.execute("SELECT name FROM companies WHERE id = ?", (cid,)).fetchone() == (expected,)
assert db.execute("SELECT company FROM prospects WHERE id = ?", (pid,)).fetchone() == (expected,)
diff --git a/tests/test_discover.py b/tests/test_discover.py
index 1aad389..5c9f9b5 100644
--- a/tests/test_discover.py
+++ b/tests/test_discover.py
@@ -8,6 +8,7 @@ anyone, and that directories never make it in.
import asyncio
import os
+from contextlib import closing
import tempfile
import httpx
@@ -732,7 +733,7 @@ async def test_directory_title_still_filtered_after_adapter(provider, tmp_path,
assert report.found == 2
assert report.new_companies == 1
import sqlite3
- with sqlite3.connect(state.db_path) as db:
+ with closing(sqlite3.connect(state.db_path)) as db:
assert db.execute("SELECT domain, name FROM companies").fetchall() == [
("kettlemanroofing.com", "Kettleman Roofing")]