Skip to content

Commit

Permalink
Remove unused coverage rules, mark PYTHONMALLOC no cover, and stop pr…
Browse files Browse the repository at this point in the history
…inting coverage env vars in tox
  • Loading branch information
rmartin16 committed May 8, 2023
1 parent f6f16a2 commit 0740657
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 45 deletions.
20 changes: 1 addition & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,15 @@ exclude_lines = [
]

[tool.coverage.coverage_conditional_plugin.rules]
# Packages/Modules
no-cover-if-missing-setuptools_scm = "not is_installed('setuptools_scm')"
# Linux
no-cover-if-is-linux = "'linux' == os_environ.get('COVERAGE_PLATFORM', sys_platform) and os_environ.get('COVERAGE_EXCLUDE_PLATFORM') != 'disable'"
no-cover-if-not-linux = "'linux' != os_environ.get('COVERAGE_PLATFORM', sys_platform) and os_environ.get('COVERAGE_EXCLUDE_PLATFORM') != 'disable'"
# macOS
no-cover-if-is-macos = "'darwin' == os_environ.get('COVERAGE_PLATFORM', sys_platform) and os_environ.get('COVERAGE_EXCLUDE_PLATFORM') != 'disable'"
no-cover-if-not-macos = "'darwin' != os_environ.get('COVERAGE_PLATFORM', sys_platform) and os_environ.get('COVERAGE_EXCLUDE_PLATFORM') != 'disable'"
# Windows
no-cover-if-is-windows = "'win32' == os_environ.get('COVERAGE_PLATFORM', sys_platform) and os_environ.get('COVERAGE_EXCLUDE_PLATFORM') != 'disable'"
no-cover-if-not-windows = "'win32' != os_environ.get('COVERAGE_PLATFORM', sys_platform) and os_environ.get('COVERAGE_EXCLUDE_PLATFORM') != 'disable'"
# Python 3.12
no-cover-if-is-py312 = "python_version == '3.12' and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
no-cover-if-lt-py312 = "sys_version_info < (3, 12) and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
no-cover-if-gte-py312 = "sys_version_info > (3, 12) and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
# Python 3.11
no-cover-if-is-py311 = "python_version == '3.11' and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
no-cover-if-lt-py311 = "sys_version_info < (3, 11) and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
no-cover-if-gte-py311 = "sys_version_info > (3, 11) and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
# Python 3.10
no-cover-if-is-py310 = "python_version == '3.10' and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
no-cover-if-lt-py310 = "sys_version_info < (3, 10) and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
no-cover-if-gte-py310 = "sys_version_info > (3, 10) and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
# Python 3.9
no-cover-if-is-py39 = "python_version == '3.9' and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
no-cover-if-lt-py39 = "sys_version_info < (3, 9) and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
no-cover-if-gte-py39 = "sys_version_info > (3, 9) and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"

# Python 3.8
no-cover-if-is-py38 = "python_version == '3.8' and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"

Expand Down
3 changes: 2 additions & 1 deletion src/briefcase/commands/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ def get_environment(self, app, test_mode: bool):
# On Windows, we need to disable the debug allocator because it
# conflicts with Python.net. See
# https://github.com/pythonnet/pythonnet/issues/1977 for details.
if self.platform == "windows":
# marking no cover since a single platform cannot take both branches
if self.platform == "windows": # pragma: no cover
env["PYTHONMALLOC"] = "default"

return env
Expand Down
17 changes: 0 additions & 17 deletions tests/commands/dev/test_get_environment.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
import sys
from pathlib import Path
from unittest.mock import PropertyMock

import pytest

PYTHONPATH = "PYTHONPATH"
PYTHONMALLOC = "PYTHONMALLOC"


@pytest.mark.parametrize("platform", ["windows", "darwin", "linux", "wonky"])
def test_pythonmalloc_only_set_for_windows(
dev_command,
first_app,
platform,
monkeypatch,
):
"""PYTHONMALLOC env var is only set on Windows."""
monkeypatch.setattr(
type(dev_command), "platform", PropertyMock(return_value=platform)
)
env = dev_command.get_environment(first_app, test_mode=False)
expected = "default" if platform == "windows" else "missing"
assert env.get(PYTHONMALLOC, "missing") == expected


@pytest.mark.skipif(sys.platform != "win32", reason="Relevant only for windows")
def test_pythonpath_with_one_source_in_windows(dev_command, first_app):
"""Test get environment with one source."""
Expand Down
9 changes: 1 addition & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,7 @@ setenv =
{platform,project}: COVERAGE_EXCLUDE_PYTHON_VERSION=disable
# disable coverage exclusions for host platform to test entire project
project: COVERAGE_EXCLUDE_PLATFORM=disable
commands_pre =
python --version
python -c 'if 1: \
import os; \
print("COVERAGE_FILE", os.environ.get("COVERAGE_FILE", "<not set>")); \
print("COVERAGE_PLATFORM", os.environ.get("COVERAGE_PLATFORM", "<not set>")); \
print("COVERAGE_EXCLUDE_PYTHON_VERSION", os.environ.get("COVERAGE_EXCLUDE_PYTHON_VERSION", "<not set>")); \
print("COVERAGE_EXCLUDE_PLATFORM", os.environ.get("COVERAGE_EXCLUDE_PLATFORM", "<not set>"))'
commands_pre = python --version
commands =
-python -m coverage combine {env:COMBINE_FLAGS}
html: python -m coverage html --skip-covered --skip-empty
Expand Down

0 comments on commit 0740657

Please sign in to comment.