Skip to content

Commit ea991d9

Browse files
committed
fix tests
1 parent 373a736 commit ea991d9

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

src/gitingest/__main__.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,12 @@ async def _async_main(
189189
logger.exception("Ingest failed.", exc_info=exc)
190190
raise click.Abort from exc
191191

192-
if output_target == "-": # stdout
193-
logger.info("--- Summary ---")
194-
logger.info(summary)
195-
logger.info("--- End Summary ---")
196-
logger.info("Analysis complete! Output sent to stdout.")
197-
else: # file
198-
logger.info("Analysis complete! Output written to: %s", output_target)
199-
logger.info("Summary:")
200-
logger.info(summary)
192+
if output_target == "-":
193+
click.echo(f"--- Summary ---\n{summary}\n--- End Summary ---", err=True)
194+
click.echo("Analysis complete! Output sent to stdout.", err=True)
195+
else:
196+
click.echo(f"Analysis complete! Output written to: {output_target}")
197+
click.echo(f"Summary:\n{summary}")
201198

202199

203200
if __name__ == "__main__":

src/gitingest/utils/notebook.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import json
66
import logging
7+
import warnings
78
from itertools import chain
89
from typing import TYPE_CHECKING, Any
910

@@ -47,16 +48,20 @@ def process_notebook(file: Path, *, include_output: bool = True) -> str:
4748
# Check if the notebook contains worksheets
4849
worksheets = notebook.get("worksheets")
4950
if worksheets:
50-
logger.warning(
51+
warnings.warn(
5152
"Worksheets are deprecated as of IPEP-17. Consider updating the notebook. "
5253
"(See: https://github.com/jupyter/nbformat and "
5354
"https://github.com/ipython/ipython/wiki/IPEP-17:-Notebook-Format-4#remove-multiple-worksheets "
5455
"for more information.)",
56+
DeprecationWarning,
57+
stacklevel=2,
5558
)
5659

5760
if len(worksheets) > 1:
58-
logger.warning(
61+
warnings.warn(
5962
"Multiple worksheets detected. Combining all worksheets into a single script.",
63+
UserWarning,
64+
stacklevel=2,
6065
)
6166

6267
cells = list(chain.from_iterable(ws["cells"] for ws in worksheets))

tests/test_summary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_ingest_summary(path_type: str, path: str, ref_type: str, ref: str) -> N
5555
is_blob = path_type == "blob"
5656
expected_lines = _calculate_expected_lines(ref_type, is_main_branch=is_main_branch)
5757
expected_non_empty_lines = expected_lines - 1
58-
58+
print(f"https://github.com/{REPO}/{path_type}/{ref}{path}")
5959
summary, _, _ = ingest(f"https://github.com/{REPO}/{path_type}/{ref}{path}")
6060
lines = summary.splitlines()
6161
parsed_lines = dict(line.split(": ", 1) for line in lines if ": " in line)

0 commit comments

Comments
 (0)