Skip to content

Commit

Permalink
Enforce 100% coverage (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex authored Sep 29, 2024
1 parent 293ea34 commit 24d5f57
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
- name: Install dependencies
run: uv sync --python ${{ matrix.python-version }} --frozen

- name: Run tests
run: scripts/test

- name: Run linters
run: scripts/lint

- name: Run tests
run: scripts/test

# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check:
if: always()
Expand Down
2 changes: 1 addition & 1 deletion multipart/decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def finalize(self) -> None:
call it.
"""
# If we have a cache, write and then remove it.
if len(self.cache) > 0:
if len(self.cache) > 0: # pragma: no cover
self.underlying.write(binascii.a2b_qp(self.cache))
self.cache = b""

Expand Down
12 changes: 2 additions & 10 deletions multipart/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ class MultipartState(IntEnum):
# fmt: on


def ord_char(c: int) -> int:
return c


def parse_options_header(value: str | bytes) -> tuple[bytes, dict[bytes, bytes]]:
"""Parses a Content-Type header into a value in the following format: (content_type, {parameters})."""
# Uses email.message.Message to parse the header as described in PEP 594.
Expand Down Expand Up @@ -473,7 +469,7 @@ def _get_disk_file(self) -> io.BufferedRandom | tempfile._TemporaryFileWrapper[b
elif isinstance(file_dir, bytes):
dir = file_dir.decode(sys.getfilesystemencoding())
else:
dir = file_dir
dir = file_dir # pragma: no cover

# Create a temporary (named) file with the appropriate settings.
self.logger.info(
Expand Down Expand Up @@ -511,11 +507,7 @@ def on_data(self, data: bytes) -> int:
Returns:
The number of bytes written.
"""
pos = self._fileobj.tell()
bwritten = self._fileobj.write(data)
# true file objects write returns None
if bwritten is None:
bwritten = self._fileobj.tell() - pos

# If the bytes written isn't the same as the length, just return.
if bwritten != len(data):
Expand Down Expand Up @@ -1381,7 +1373,7 @@ def data_callback(name: str, end_i: int, remaining: bool = False) -> None:
elif state == MultipartState.END:
# Do nothing and just consume a byte in the end state.
if c not in (CR, LF):
self.logger.warning("Consuming a byte '0x%x' in the end state", c)
self.logger.warning("Consuming a byte '0x%x' in the end state", c) # pragma: no cover

else: # pragma: no cover (error case)
# We got into a strange state somehow! Just stop processing.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ branch = false
omit = ["tests/*"]

[tool.coverage.report]
# fail_under = 100
fail_under = 100
skip_covered = true
show_missing = true
exclude_lines = [
Expand Down

0 comments on commit 24d5f57

Please sign in to comment.