mirror of
https://github.com/kevinveenbirkenbach/directory-content-scanner.git
synced 2026-02-08 23:13:13 +00:00
This commit introduces a complete structural and architectural refactor of
Analysis-Ready Code (ARC). The project is now fully migrated to a modern src/-based Python package layout, with proper packaging via pyproject.toml, a clean Nix flake, and improved CLI entry points. Major changes: • Add `src/arc/` package with clean module structure: - arc/__init__.py now contains the main() dispatcher and clipboard helpers - arc/__main__.py provides a proper `python -m arc` entry point - arc/cli.py rewritten with full argparse-based interface - arc/code_processor.py modernized and relocated - arc/directory_handler.py rewritten with output_stream support - arc/tee.py added for multi-stream output (stdout + buffer) • Remove legacy top-level modules: - cli.py - directory_handler.py - main.py • Introduce fully PEP-517 compliant pyproject.toml with console script: - arc = arc.__main__:main • Add Nix flake (`flake.nix`) providing: - buildPythonApplication package `arc` - `nix run .#arc` app - development shell with Python + xclip • Add Makefile overhaul: - automatic detection of Nix vs Python installation - unified install/uninstall targets - Nix wrapper installation into ~/.local/bin - improved help text and shell safety • Add GitHub CI pipelines: - ci-python.yml for Python builds + Makefile tests + arc --help - ci-nix.yml for Nix builds, flake checks, dev-shell tests, and `nix run .#arc` • Refactor and extend unit tests: - test_arc.py updated for src/ imports - new tests: test_cli.py, test_main.py, test_tee.py - improved CodeProcessor and DirectoryHandler tests • Add egg-info metadata for local builds • Add build/lib/ tree for compatibility with setuptools (generated) Overall, this commit modernizes ARC into a clean, robust, and fully packaged Python/Nix hybrid tool, enabling reproducible builds, solid CLI behavior, testable architecture, and CI automation. https://chatgpt.com/share/693933a0-e280-800f-9cf0-26036d15be04
This commit is contained in:
54
tests/unit/test_tee.py
Normal file
54
tests/unit/test_tee.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# tests/unit/test_tee.py
|
||||
import io
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
# Ensure src/ is on sys.path when running via discover
|
||||
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
SRC_ROOT = os.path.join(PROJECT_ROOT, "src")
|
||||
if SRC_ROOT not in sys.path:
|
||||
sys.path.insert(0, SRC_ROOT)
|
||||
|
||||
from arc.tee import Tee # noqa: E402
|
||||
|
||||
|
||||
class TestTee(unittest.TestCase):
|
||||
def test_write_writes_to_all_streams(self):
|
||||
buf1 = io.StringIO()
|
||||
buf2 = io.StringIO()
|
||||
|
||||
tee = Tee(buf1, buf2)
|
||||
tee.write("hello")
|
||||
tee.write(" world")
|
||||
|
||||
self.assertEqual(buf1.getvalue(), "hello world")
|
||||
self.assertEqual(buf2.getvalue(), "hello world")
|
||||
|
||||
def test_flush_flushes_all_streams(self):
|
||||
class DummyStream:
|
||||
def __init__(self):
|
||||
self.flushed = False
|
||||
self.data = ""
|
||||
|
||||
def write(self, s):
|
||||
self.data += s
|
||||
|
||||
def flush(self):
|
||||
self.flushed = True
|
||||
|
||||
s1 = DummyStream()
|
||||
s2 = DummyStream()
|
||||
|
||||
tee = Tee(s1, s2)
|
||||
tee.write("x")
|
||||
tee.flush()
|
||||
|
||||
self.assertTrue(s1.flushed)
|
||||
self.assertTrue(s2.flushed)
|
||||
self.assertEqual(s1.data, "x")
|
||||
self.assertEqual(s2.data, "x")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user