Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion barcode/isxn.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _calculate_checksum(self):
11
- sum(x * int(y) for x, y in enumerate(reversed(self.issn[:7]), start=2))
% 11
)
) % 11
if tmp == 10:
return "X"

Expand Down
13 changes: 13 additions & 0 deletions tests/test_checksums.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,16 @@ def test_isbn13_checksum() -> None:
def test_gs1_128_checksum() -> None:
gs1_128 = get_barcode("gs1_128", "00376401856400470087")
assert gs1_128.get_fullcode() == "00376401856400470087"


def test_issn_checksum_zero() -> None:
# When the weighted sum is divisible by 11, the checksum should be 0,
# not 11. Regression test for issue #238.
issn = get_barcode("issn", "6727893")
assert issn.issn == "67278930" # type: ignore[attr-defined]


def test_issn_checksum_x() -> None:
# When (11 - weighted_sum % 11) % 11 == 10, checksum should be "X".
issn = get_barcode("issn", "0000006")
assert issn.issn == "0000006X" # type: ignore[attr-defined]
Loading