Skip to content

Commit 6c227b0

Browse files
bartTCakx
andauthored
Coverage Improvements (#404)
* Improve test coverage * Coverage settings * Ruff autoformat * Update changelog --------- Co-authored-by: Aarni Koskela <[email protected]>
1 parent b75b160 commit 6c227b0

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ WIP
66
===
77

88
- Added ``GappedCircleModuleDrawer`` (PIL) to render QR code modules as non-contiguous circles. (BenwestGate in `#373`_)
9+
- Improved test coveraged (akx in `#315`_)
910
- Migrate pyproject.toml to PEP 621-compliant [project] metadata format. (hroncok in `#399`_)
1011
- Allow execution as a Python module. (stefansjs in `#400`_)
1112

1213
::
1314

1415
python -m qrcode --output qrcode.png "hello world"
1516

17+
.. _#315: https://github.com/lincolnloop/python-qrcode/pull/315
1618
.. _#373: https://github.com/lincolnloop/python-qrcode/pull/373
1719
.. _#399: https://github.com/lincolnloop/python-qrcode/pull/399
1820
.. _#400: https://github.com/lincolnloop/python-qrcode/pull/400

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,17 @@ date-format =" %%-d %%B %%Y"
8080
prereleaser.middle = [
8181
"qrcode.release.update_manpage"
8282
]
83+
84+
[tool.coverage.run]
85+
source = ["qrcode"]
86+
parallel = true
87+
88+
[tool.coverage.report]
89+
exclude_lines = [
90+
"@abc.abstractmethod",
91+
"@overload",
92+
"if (typing\\.)?TYPE_CHECKING:",
93+
"pragma: no cover",
94+
"raise NotImplementedError"
95+
]
96+
skip_covered = true

qrcode/image/styledpil.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ def draw_embedded_image(self):
122122
def save(self, stream, format=None, **kwargs):
123123
if format is None:
124124
format = kwargs.get("kind", self.kind)
125-
if "kind" in kwargs:
126-
del kwargs["kind"]
125+
kwargs.pop("kind", None)
127126
self._img.save(stream, format=format, **kwargs)
128127

129128
def __getattr__(self, name):
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# For backwards compatibility, importing the PIL drawers here.
22
try:
33
from .pil import CircleModuleDrawer # noqa: F401
4-
from .pil import GappedCircleModuleDrawer # noqa: F401
4+
from .pil import GappedCircleModuleDrawer # noqa: F401
55
from .pil import GappedSquareModuleDrawer # noqa: F401
66
from .pil import HorizontalBarsDrawer # noqa: F401
77
from .pil import RoundedModuleDrawer # noqa: F401
88
from .pil import SquareModuleDrawer # noqa: F401
99
from .pil import VerticalBarsDrawer # noqa: F401
10-
except ImportError:
10+
except ImportError: # pragma: no cover
1111
pass

qrcode/image/styles/moduledrawers/pil.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ def initialize(self, *args, **kwargs):
117117
(0, 0, fake_size, fake_size), fill=self.img.paint_color
118118
)
119119
smaller_size = int(self.size_ratio * box_size)
120-
self.circle = self.circle.resize((smaller_size, smaller_size), Image.Resampling.LANCZOS)
120+
self.circle = self.circle.resize(
121+
(smaller_size, smaller_size), Image.Resampling.LANCZOS
122+
)
121123

122124
def drawrect(self, box, is_active: bool):
123125
if is_active:

0 commit comments

Comments
 (0)