From e932e62c26be3a9b18f6f43ab7753ab96c4fa405 Mon Sep 17 00:00:00 2001 From: Josh Karpel Date: Sat, 7 Nov 2020 12:22:54 -0600 Subject: [PATCH] Version 0.1.4 (#10) * bump to v0.1.4; codecov in CI * add env vars to codecov upload * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * tweak coverage settings, add codecov badge to README.md * turns out "hi" is a perfectly valid two-character fragment of a 30-character random string... Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .coveragerc | 23 +++++++++++++++++++++++ .github/workflows/tests.yml | 11 ++++++++++- .pre-commit-config.yaml | 4 ---- README.md | 2 ++ pyproject.toml | 3 +-- setup.cfg | 3 ++- tests/conftest.py | 16 +++------------- 7 files changed, 41 insertions(+), 21 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..bceafc6 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,23 @@ +[run] + +branch = True + +source = + dis_cli + tests/ + +[report] + +exclude_lines = + pragma: no cover + pragma: unlikely + + def __repr__ + if self\.debug + + raise AssertionError + raise NotImplementedError + + if 0: + if False: + if __name__ == .__main__.: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index adc5f68..3ceadc5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,6 +16,10 @@ jobs: runs-on: ${{ matrix.platform }} + env: + PLATFORM: ${{ matrix.platform }} + PYTHON_VERSION: ${{ matrix.python-version }} + steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} @@ -25,4 +29,9 @@ jobs: - name: Install package run: pip install .[tests] - name: Run tests - run: pytest tests/ + run: pytest --cov --cov-report=xml tests/ + - uses: codecov/codecov-action@v1 + with: + env_vars: PLATFORM,PYTHON_VERSION + fail_ci_if_error: true + verbose: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 03493ea..eb15cfc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,7 +33,3 @@ repos: rev: 5.6.4 hooks: - id: isort -# - repo: https://github.com/pre-commit/mirrors-mypy -# rev: v0.782 -# hooks: -# - id: mypy diff --git a/README.md b/README.md index 0da9b62..dbfd568 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # dis-cli ![PyPI](https://img.shields.io/pypi/v/dis-cli) + [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/JoshKarpel/dis-cli/master.svg)](https://results.pre-commit.ci/latest/github/JoshKarpel/dis-cli/master) +[![codecov](https://codecov.io/gh/JoshKarpel/dis-cli/branch/master/graph/badge.svg?token=Y4LLQ82PZ1)](https://codecov.io/gh/JoshKarpel/dis-cli) `dis-cli` is a command line tool for displaying Python source and bytecode. diff --git a/pyproject.toml b/pyproject.toml index ba41de9..13686de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,9 +9,8 @@ include = "\\.pyi?$" [tool.isort] known_third_party = ["click", "pytest", "rich", "setuptools"] +profile = "black" line_length = 100 -multi_line_output = "VERTICAL_HANGING_INDENT" -include_trailing_comma = true [tool.pytest.ini_options] testpaths = ["tests"] diff --git a/setup.cfg b/setup.cfg index 93c93d5..759303a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = dis_cli -version = 0.1.3 +version = 0.1.4 description = A tool to inspect disassembled Python code on the command line. long_description = file: README.md long_description_content_type = text/markdown @@ -41,6 +41,7 @@ console_scripts = [options.extras_require] tests = pytest>=6 + pytest-cov==2.10.1 [mypy] files = dis_cli.py, tests/*.py diff --git a/tests/conftest.py b/tests/conftest.py index 229abca..a421003 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,9 +11,6 @@ import dis_cli -USED_FILENAMES = set() -FILENAME_LENGTH = 30 - @pytest.fixture def filename() -> str: @@ -24,17 +21,10 @@ def filename() -> str: Without this, if we run the CLI on two modules with different contents but the same filename during a test session, the second run will see the contents of the first module. """ - name = "".join(random.choices(string.ascii_letters, k=FILENAME_LENGTH)) - - while name in USED_FILENAMES: - name = "".join(random.choices(string.ascii_letters, k=FILENAME_LENGTH)) - - USED_FILENAMES.add(name) + return "_".join(random.choices(string.ascii_uppercase, k=30)) - return name - -@pytest.fixture +@pytest.fixture(scope="session") def runner() -> CliRunner: return CliRunner() @@ -56,7 +46,7 @@ def invoke_with_debug(runner: CliRunner, cli, *args, **kwargs) -> Result: return result -@pytest.fixture +@pytest.fixture(scope="session") def cli(runner): return functools.partial(invoke_with_debug, runner, dis_cli.cli)