Skip to content

Commit

Permalink
Merge branch 'master' of github.com:tonybaloney/wily
Browse files Browse the repository at this point in the history
  • Loading branch information
tonybaloney committed Oct 11, 2023
2 parents ee7014a + a79b62e commit 4ac2334
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 64 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ jobs:
- '3.9'
- '3.10'
- '3.11'
continue-on-error:
- false
- '3.12'
runs-on: "${{ matrix.os }}"
continue-on-error: "${{ matrix.continue-on-error }}"
continue-on-error: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand Down
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
A command-line application for tracking, reporting on complexity of Python tests and applications.

[![Wily](https://img.shields.io/badge/%F0%9F%A6%8A%20wily-passing-brightgreen.svg)](https://wily.readthedocs.io/)
[![codecov](https://codecov.io/gh/tonybaloney/wily/branch/master/graph/badge.svg)](https://codecov.io/gh/tonybaloney/wily) [![Documentation Status](https://readthedocs.org/projects/wily/badge/?version=latest)](https://wily.readthedocs.io/en/latest/?badge=latest) [![PyPI version](https://badge.fury.io/py/wily.svg)](https://badge.fury.io/py/wily) [![Conda Version](https://img.shields.io/conda/vn/conda-forge/wily.svg)](https://anaconda.org/conda-forge/wily) ![black](https://img.shields.io/badge/code%20style-black-000000.svg)
[![codecov](https://codecov.io/gh/tonybaloney/wily/branch/master/graph/badge.svg)](https://codecov.io/gh/tonybaloney/wily) [![Documentation Status](https://readthedocs.org/projects/wily/badge/?version=latest)](https://wily.readthedocs.io/en/latest/?badge=latest) [![PyPI version](https://badge.fury.io/py/wily.svg)](https://badge.fury.io/py/wily) [![Conda Version](https://img.shields.io/conda/vn/conda-forge/wily.svg)](https://anaconda.org/conda-forge/wily) ![black](https://img.shields.io/badge/code%20style-black-000000.svg) ![PyPI - Downloads](https://img.shields.io/pypi/dm/wily)


```
```default
wily [a]:
quick to think of things, having a very good understanding of situations and possibilities,
and often willing to use tricks to achieve an aim.
Expand Down Expand Up @@ -42,7 +41,7 @@ Wily can be used via a command line interface, `wily`.

## Demo

Here is a demo of wily analysing a Python project, giving a summary of changes to complexity in the last 10 commits and then showing changes against a specific git revision:
Here is a demo of wily analysing a Python project, giving a summary of changes to complexity in the last 10 commits and then showing changes against a specific git revision:

![demo](./docs/source/_static/termtosvg_leo0ur6s.svg)

Expand Down Expand Up @@ -86,7 +85,7 @@ repos:

The first step to using `wily` is to build a wily cache with the statistics of your project.

```
```default
Usage: __main__.py build [OPTIONS] [TARGETS]...
Build the wily cache
Expand All @@ -108,7 +107,6 @@ Limit the number of revisions (defaults to 50).

![wily-build](https://github.com/tonybaloney/wily/raw/master/docs/source/_static/wily_build.png)


#### `wily report`

Show a specific metric for a given file, requires that `.wily/` exists
Expand Down Expand Up @@ -139,7 +137,6 @@ Show information about the build directory. Requires that `.wily/` exists.

![wily-graph](https://github.com/tonybaloney/wily/raw/master/docs/source/_static/wily_index.png)

### `wily list-metrics`

List the metrics available in the Wily operators. Each one of the metrics can be used in `wily graph` and `wily report`
Expand Down Expand Up @@ -203,7 +200,6 @@ Wily will detect and scan all Python code in .ipynb files automatically.
You can disable this behaviour if you require by setting `ipynb_support = false` in the configuration.
You can also disable the behaviour of reporting on individual cells by setting `ipynb_cells = false`.


# Credits

## Contributors
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
]
dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_build_crash(tmpdir):
) as bar_finish:
runner = CliRunner()
result = runner.invoke(main.cli, ["--path", tmpdir, "build", "test.py"])
assert bar_finish.called_once
assert bar_finish.called
assert result.exit_code == 1, result.stdout


Expand Down
97 changes: 45 additions & 52 deletions test/unit/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
from wily.helper.custom_enums import ReportFormat


def test_init():
with patch.object(main, "cli", return_value=None) as cli:
with patch.object(main, "__name__", "__main__"):
__import__("wily.__main__")
assert cli.called_once


def test_help():
"""
Test that CLI when called with help options
Expand All @@ -33,7 +26,7 @@ def test_setup():
runner = CliRunner()
result = runner.invoke(main.cli, ["setup"])
assert result.exit_code == 0
assert handle_no_cache.called_once
assert handle_no_cache.called


def test_handle_no_cache_no():
Expand All @@ -43,7 +36,7 @@ def test_handle_no_cache_no():
with patch("wily.__main__.input", return_value="n") as mock_input:
with pytest.raises(SystemExit):
main.handle_no_cache(None)
assert mock_input.called_once
assert mock_input.called


def test_handle_no_cache():
Expand All @@ -55,8 +48,10 @@ def test_handle_no_cache():
runner = CliRunner()
runner.invoke(main.cli, ["setup"])
assert mock_input.called
assert build_command.called_once
assert build_command.called_with("1")
assert build_command.called
build_command.assert_called_with(
max_revisions=11, targets=["."], operators=None
)


def test_build():
Expand All @@ -67,7 +62,7 @@ def test_build():
runner = CliRunner()
result = runner.invoke(main.cli, ["build", "wily"])
assert result.exit_code == 0
assert build.called_once
assert build.called


def test_build_with_opts():
Expand All @@ -80,7 +75,7 @@ def test_build_with_opts():
main.cli, ["build", "wily", "-n 1", "-o raw,maintainability"]
)
assert result.exit_code == 0
assert build.called_once
assert build.called
assert build.call_args[1]["config"].max_revisions == 1
assert build.call_args[1]["config"].operators == ["raw", "maintainability"]

Expand All @@ -94,8 +89,8 @@ def test_index():
runner = CliRunner()
result = runner.invoke(main.cli, ["index"])
assert result.exit_code == 0
assert index.called_once
assert check_cache.called_once
assert index.called
assert check_cache.called


def test_index_with_opts():
Expand All @@ -107,8 +102,8 @@ def test_index_with_opts():
runner = CliRunner()
result = runner.invoke(main.cli, ["index", "--message"])
assert result.exit_code == 0
assert index.called_once
assert check_cache.called_once
assert index.called
assert check_cache.called
assert index.call_args[1]["include_message"]


Expand All @@ -121,8 +116,8 @@ def test_index_with_no_message():
runner = CliRunner()
result = runner.invoke(main.cli, ["index", "--no-message"])
assert result.exit_code == 0
assert index.called_once
assert check_cache.called_once
assert index.called
assert check_cache.called
assert not index.call_args[1]["include_message"]


Expand All @@ -139,12 +134,12 @@ def test_report():
runner = CliRunner()
result = runner.invoke(main.cli, ["report", "foo.py"])
assert result.exit_code == 0, result.stdout
assert report.called_once
assert check_cache.called_once
assert report.called
assert check_cache.called
assert report.call_args[1]["path"] == "foo.py"
assert report.call_args[1]["format"] == ReportFormat.CONSOLE
assert "maintainability.mi" in report.call_args[1]["metrics"]
assert gdf.called_once
assert gdf.called


def test_report_with_opts():
Expand All @@ -158,8 +153,8 @@ def test_report_with_opts():
main.cli, ["report", "foo.py", "example_metric", "-n 101", "--message"]
)
assert result.exit_code == 0, result.stdout
assert report.called_once
assert check_cache.called_once
assert report.called
assert check_cache.called
assert report.call_args[1]["path"] == "foo.py"
assert report.call_args[1]["metrics"] == ("example_metric",)
assert report.call_args[1]["include_message"]
Expand Down Expand Up @@ -187,8 +182,8 @@ def test_report_html_format():
)

assert result.exit_code == 0, result.stdout
assert report.called_once
assert check_cache.called_once
assert report.called
assert check_cache.called
assert report.call_args[1]["path"] == "foo.py"
assert report.call_args[1]["metrics"] == ("example_metric",)
assert report.call_args[1]["include_message"]
Expand All @@ -215,8 +210,8 @@ def test_report_console_format():
],
)
assert result.exit_code == 0, result.stdout
assert report.called_once
assert check_cache.called_once
assert report.called
assert check_cache.called
assert report.call_args[1]["path"] == "foo.py"
assert report.call_args[1]["metrics"] == ("example_metric",)
assert report.call_args[1]["include_message"]
Expand All @@ -243,8 +238,6 @@ def test_report_not_existing_format():
],
)
assert result.exit_code == 2, result.stdout
assert report.called_once
assert check_cache.called_once


def test_report_html_format_with_output():
Expand All @@ -268,8 +261,8 @@ def test_report_html_format_with_output():
)

assert result.exit_code == 0, result.stdout
assert report.called_once
assert check_cache.called_once
assert report.called
assert check_cache.called
assert report.call_args[1]["path"] == "foo.py"
assert report.call_args[1]["metrics"] == ("example_metric",)
assert report.call_args[1]["include_message"]
Expand All @@ -291,8 +284,8 @@ def test_graph():
main.cli, ["graph", "foo.py", "-m", "example_metric"]
)
assert result.exit_code == 0
assert graph.called_once
assert check_cache.called_once
assert graph.called
assert check_cache.called
assert graph.call_args[1]["path"] == ("foo.py",)
assert graph.call_args[1]["metrics"] == "example_metric"

Expand All @@ -309,8 +302,8 @@ def test_graph_multiple_paths():
["graph", "foo.py", "bar.py", "baz.py", "-m", "example_metric"],
)
assert result.exit_code == 0
assert graph.called_once
assert check_cache.called_once
assert graph.called
assert check_cache.called
assert graph.call_args[1]["path"] == ("foo.py", "bar.py", "baz.py")
assert graph.call_args[1]["metrics"] == "example_metric"

Expand All @@ -326,8 +319,8 @@ def test_graph_multiple_metrics():
main.cli, ["graph", "foo.py", "-m", "example_metric,another_metric"]
)
assert result.exit_code == 0
assert graph.called_once
assert check_cache.called_once
assert graph.called
assert check_cache.called
assert graph.call_args[1]["path"] == ("foo.py",)
assert graph.call_args[1]["metrics"] == "example_metric,another_metric"

Expand All @@ -343,8 +336,8 @@ def test_graph_with_output():
main.cli, ["graph", "foo.py", "-m", "example_metric", "-o", "foo.html"]
)
assert result.exit_code == 0
assert graph.called_once
assert check_cache.called_once
assert graph.called
assert check_cache.called
assert graph.call_args[1]["path"] == ("foo.py",)
assert graph.call_args[1]["metrics"] == "example_metric"
assert graph.call_args[1]["output"] == "foo.html"
Expand All @@ -363,10 +356,10 @@ def test_diff():
runner = CliRunner()
result = runner.invoke(main.cli, ["diff", "foo.py", "x/b.py"])
assert result.exit_code == 0
assert diff.called_once
assert check_cache.called_once
assert diff.called
assert check_cache.called
assert diff.call_args[1]["files"] == ("foo.py", "x/b.py")
assert gdf.called_once
assert gdf.called
assert "maintainability.mi" in diff.call_args[1]["metrics"]


Expand All @@ -392,8 +385,8 @@ def test_diff_with_metrics():
],
)
assert result.exit_code == 0
assert diff.called_once
assert check_cache.called_once
assert diff.called
assert check_cache.called
assert diff.call_args[1]["files"] == ("foo.py", "x/b.py")
assert not gdf.called
assert "maintainability.mi" in diff.call_args[1]["metrics"]
Expand All @@ -409,8 +402,8 @@ def test_clean():
runner = CliRunner()
result = runner.invoke(main.cli, ["clean", "--yes"])
assert result.exit_code == 0
assert clean.called_once
assert check_cache.called_once
assert clean.called
assert check_cache.called


def test_clean_with_prompt():
Expand All @@ -423,9 +416,9 @@ def test_clean_with_prompt():
runner = CliRunner()
result = runner.invoke(main.cli, ["clean"])
assert result.exit_code == 0
assert clean.called_once
assert check_cache.called_once
assert mock_input.called_once
assert clean.called
assert check_cache.called
assert mock_input.called


def test_clean_with_prompt_no_value():
Expand All @@ -439,5 +432,5 @@ def test_clean_with_prompt_no_value():
result = runner.invoke(main.cli, ["clean"])
assert result.exit_code == 0
assert not clean.called
assert check_cache.called_once
assert mock_input.called_once
assert check_cache.called
assert mock_input.called

0 comments on commit 4ac2334

Please sign in to comment.