Skip to content

Commit 24d5f57

Browse files
authored
Enforce 100% coverage (#159)
1 parent 293ea34 commit 24d5f57

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ jobs:
2727
- name: Install dependencies
2828
run: uv sync --python ${{ matrix.python-version }} --frozen
2929

30-
- name: Run tests
31-
run: scripts/test
32-
3330
- name: Run linters
3431
run: scripts/lint
3532

33+
- name: Run tests
34+
run: scripts/test
35+
3636
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
3737
check:
3838
if: always()

multipart/decoders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def finalize(self) -> None:
160160
call it.
161161
"""
162162
# If we have a cache, write and then remove it.
163-
if len(self.cache) > 0:
163+
if len(self.cache) > 0: # pragma: no cover
164164
self.underlying.write(binascii.a2b_qp(self.cache))
165165
self.cache = b""
166166

multipart/multipart.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@ class MultipartState(IntEnum):
142142
# fmt: on
143143

144144

145-
def ord_char(c: int) -> int:
146-
return c
147-
148-
149145
def parse_options_header(value: str | bytes) -> tuple[bytes, dict[bytes, bytes]]:
150146
"""Parses a Content-Type header into a value in the following format: (content_type, {parameters})."""
151147
# Uses email.message.Message to parse the header as described in PEP 594.
@@ -473,7 +469,7 @@ def _get_disk_file(self) -> io.BufferedRandom | tempfile._TemporaryFileWrapper[b
473469
elif isinstance(file_dir, bytes):
474470
dir = file_dir.decode(sys.getfilesystemencoding())
475471
else:
476-
dir = file_dir
472+
dir = file_dir # pragma: no cover
477473

478474
# Create a temporary (named) file with the appropriate settings.
479475
self.logger.info(
@@ -511,11 +507,7 @@ def on_data(self, data: bytes) -> int:
511507
Returns:
512508
The number of bytes written.
513509
"""
514-
pos = self._fileobj.tell()
515510
bwritten = self._fileobj.write(data)
516-
# true file objects write returns None
517-
if bwritten is None:
518-
bwritten = self._fileobj.tell() - pos
519511

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

13861378
else: # pragma: no cover (error case)
13871379
# We got into a strange state somehow! Just stop processing.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ branch = false
8787
omit = ["tests/*"]
8888

8989
[tool.coverage.report]
90-
# fail_under = 100
90+
fail_under = 100
9191
skip_covered = true
9292
show_missing = true
9393
exclude_lines = [

0 commit comments

Comments
 (0)