Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/pycharting/core/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ async def get_response(self, path: str, scope: MutableMapping[str, Any]) -> Resp
return response


# Configure logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
logger = logging.getLogger(__name__)


Expand Down
18 changes: 18 additions & 0 deletions tests/pycharting/core/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,21 @@ def test_run_server_auto_port_fallback():
run_server(host="127.0.0.1", port=occupied, auto_port=True)
mock_ffp.assert_called_once_with(occupied + 1)
assert mock_uvicorn.run.call_args.kwargs["port"] == fallback


def test_import_leaves_root_logging_unconfigured():
"""Importing pycharting must not install handlers on the root logger (#100).

Run in a fresh interpreter: pytest attaches its own capture handlers to the
root logger, so an in-process check would never see an empty list.
"""
import subprocess
import sys

result = subprocess.run(
[sys.executable, "-c", "import logging, pycharting; print(logging.getLogger().handlers)"],
capture_output=True,
text=True,
check=True,
)
assert result.stdout.strip() == "[]"
Loading