Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
"""Unit tests for the docs-coverage join (stdlib only)."""
from __future__ import annotations
import tempfile
import unittest
from pathlib import Path
import coverage
import extract
POLICY = {
"lanes": {"docs": {"e2e": "docs"}, "shell": {"e2e": "docs"}, "container": {"e2e": "container"}},
"skip": {},
}
class CoverageTest(unittest.TestCase):
def setUp(self):
tmp = Path(tempfile.mkdtemp())
(tmp / "p.mdx").write_text(
'```python test="docs" id="a"\nx\n```\n'
'```python test="docs,container" id="b"\nx\n```\n'
'```bash test="shell" id="c"\nx\n```\n'
)
self.blocks = extract.all_blocks(tmp)
def row(self, block_id, lane, status):
return {"block_id": block_id, "lane": lane, "status": status, "test": f"t[{block_id}]"}
def test_every_block_of_a_ran_lane_needs_a_passing_result(self):
results = [self.row("p#a", "docs", "pass"), self.row("p#b", "docs", "fail")]
rows, problems = coverage.join(self.blocks, results, POLICY, {"docs"})
self.assertEqual(
[(r["block_id"], r["status"]) for r in rows],
[("p#a", "pass"), ("p#b", "fail"), ("p#c", "missing")],
)
self.assertEqual(len(problems), 2)
self.assertIn("p#b (docs) failed", problems[0])
self.assertIn("p#c (shell) produced no result in lane docs", problems[1])
def test_lanes_that_did_not_run_are_ignored(self):
rows, problems = coverage.join(self.blocks, [], POLICY, {"qemu"})
self.assertEqual((rows, problems), ([], []))
def test_skips_and_xfails_are_not_missing(self):
results = [
self.row("p#b", "container", "skip"),
]
rows, problems = coverage.join(self.blocks, results, POLICY, {"container"})
self.assertEqual([(r["block_id"], r["status"]) for r in rows], [("p#b", "skip")])
self.assertEqual(problems, [])
self.assertIn("| p.mdx | 0 | 0 | 1 | 0 | 0 |", coverage.summary(rows))
if __name__ == "__main__":
unittest.main()