Skip to content

Commit d9e16c5

Browse files
committed
Consolidate test fixtures, prune stale gitignore entries, and fix doc typos
1 parent ef30fee commit d9e16c5

7 files changed

Lines changed: 31 additions & 43 deletions

File tree

‎.gitignore‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
*.py[cod]
22
*.so
33
*.egg
4-
*.egg-info
5-
dist
6-
build
7-
eggs
8-
parts
9-
bin
10-
var
11-
sdist
12-
develop-eggs
13-
.installed.cfg
14-
lib
15-
lib64
16-
.idea
4+
*.egg-info/
5+
dist/
6+
build/
7+
sdist/
8+
.idea/
179
*.swp
1810

1911
.hypothesis/
12+
.mypy_cache/
13+
.pytest_cache/
14+
.ruff_cache/
2015
.coverage
2116
htmlcov/
2217
.DS_Store

‎README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ specification to be a local user-interface issue distinct from IDNA
4040
conversion functionality.
4141

4242
For example, "Königsgäßchen" is not a permissible label as capital letters
43-
are not allowed. UTS 46 will convert this into lower case prior to applying
43+
are not allowed. UTS #46 will convert this into lower case prior to applying
4444
the IDNA conversion.
4545

4646
```pycon
@@ -78,7 +78,7 @@ Exceptions carry machine-readable attributes so that applications
7878
do not need to parse the message: `code` is a short, stable identifier
7979
for the rule that failed (listed below); and, when the failure can be
8080
attributed to a particular character, `text` (the label, or domain for
81-
UTS 46 processing, being validated), `codepoint` (the offending
81+
UTS #46 processing, being validated), `codepoint` (the offending
8282
codepoint as an integer) and `position` (its 1-based index within
8383
`text`, as quoted in the message) are set. Each is `None` when it does
8484
not apply. Message wording is not part of the API and may change.
@@ -112,8 +112,8 @@ disallowed_codepoint 75 1 Königsgäßchen
112112
| `non_canonical_alabel` | An `xn--` label is not the canonical Punycode encoding of its U-label (a "fake A-label") |
113113
| `invalid_ascii` | Byte input is not ASCII |
114114
| `invalid_utf8` | Byte input is not UTF-8 |
115-
| `uts46_disallowed` | A codepoint is disallowed by the UTS 46 mapping table |
116-
| `uts46_std3` | An ASCII character is rejected by the UTS 46 STD3 rules |
115+
| `uts46_disallowed` | A codepoint is disallowed by the UTS #46 mapping table |
116+
| `uts46_std3` | An ASCII character is rejected by the UTS #46 STD3 rules |
117117
| `unsupported_errors` | The codec was given an `errors` handler other than `strict` |
118118

119119

@@ -164,6 +164,6 @@ the tool exits with a non-zero status if any conversion failed.
164164
the IDNA technical standard, and emoji domains are broadly phased
165165
out across the domain industry due to associated security risks.
166166

167-
* **Regenerating lookup tables**. The IDNA and UTS 46 functionality
167+
* **Regenerating lookup tables**. The IDNA and UTS #46 functionality
168168
relies upon pre-calculated lookup tables, generated using the
169169
`idna-data` script in [`tools/`](tools/README.md).

‎SECURITY.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ Please disclose your issue through Github's
1515
[security advisory facility](https://github.com/kjd/idna/security/advisories/new).
1616

1717
We will endeavor to prioritize review, remediation and disclosure of
18-
vulnerabilites. However, be mindful that this project is maintained by a
18+
vulnerabilities. However, be mindful that this project is maintained by a
1919
team of volunteers who work on a best effort basis.

‎idna/core.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,9 @@ def check_label(label: str | bytes | bytearray) -> None:
466466
if len(label) == 0:
467467
raise IDNAError("Empty Label", code="empty_label")
468468

469-
# Reject on domain length rather than label length so support some UTS 46
470-
# use cases, still reducing processing of label contextual rules
469+
# Check against the domain length rather than the label length to
470+
# support some UTS #46 use cases, while still bounding the work done
471+
# by the label contextual rules below.
471472
if not valid_string_length(label, trailing_dot=True):
472473
raise IDNAError("Label too long", code="label_too_long")
473474

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ all = [
5353
"ty >= 0.0.37",
5454
"pytest >= 8.3.2",
5555
"hypothesis >= 6.141.1",
56+
"coverage >= 7.10.0",
5657
]
5758

5859
[tool.coverage.run]

‎tests/test_idna_codec.py‎

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77
CODEC_NAME = "idna2008"
88

9+
# (decoded, encoded) pairs derived from CPython's Lib/test/test_codecs.py
10+
INCREMENTAL_TESTS = (
11+
("python.org", b"python.org"),
12+
("python.org.", b"python.org."),
13+
("pyth\xf6n.org", b"xn--pythn-mua.org"),
14+
("pyth\xf6n.org.", b"xn--pythn-mua.org."),
15+
)
16+
917

1018
class IDNACodecTests(unittest.TestCase):
1119
def setUp(self):
@@ -58,16 +66,7 @@ def encode(obj):
5866
return self.idnatests.test_encode(encode=encode)
5967

6068
def testIncrementalDecoder(self):
61-
# Tests derived from Python standard library test/test_codecs.py
62-
63-
incremental_tests = (
64-
("python.org", b"python.org"),
65-
("python.org.", b"python.org."),
66-
("pyth\xf6n.org", b"xn--pythn-mua.org"),
67-
("pyth\xf6n.org.", b"xn--pythn-mua.org."),
68-
)
69-
70-
for decoded, encoded in incremental_tests:
69+
for decoded, encoded in INCREMENTAL_TESTS:
7170
self.assertEqual(
7271
"".join(codecs.iterdecode((bytes([c]) for c in encoded), CODEC_NAME)),
7372
decoded,
@@ -106,15 +105,7 @@ def testIncrementalDecoder(self):
106105
self.assertEqual(decoder.decode(b"", True), "")
107106

108107
def testIncrementalEncoder(self):
109-
# Tests derived from Python standard library test/test_codecs.py
110-
111-
incremental_tests = (
112-
("python.org", b"python.org"),
113-
("python.org.", b"python.org."),
114-
("pyth\xf6n.org", b"xn--pythn-mua.org"),
115-
("pyth\xf6n.org.", b"xn--pythn-mua.org."),
116-
)
117-
for decoded, encoded in incremental_tests:
108+
for decoded, encoded in INCREMENTAL_TESTS:
118109
self.assertEqual(b"".join(codecs.iterencode(decoded, CODEC_NAME)), encoded)
119110

120111
encoder = codecs.getincrementalencoder(CODEC_NAME)()

‎tools/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# idna-data
22

3-
The IDNA and UTS 46 functionality in this library relies upon
3+
The IDNA and UTS #46 functionality in this library relies upon
44
pre-calculated lookup tables for performance. These tables are derived
55
from computing against eligibility criteria in the respective standards
66
using the command-line script `idna-data` in this directory.
@@ -11,7 +11,7 @@ three main modes:
1111

1212
* `idna-data make-libdata`. Generates `idnadata.py` and
1313
`uts46data.py`, the pre-calculated lookup tables used for IDNA and
14-
UTS 46 conversions. Implementers who wish to track this library against
14+
UTS #46 conversions. Implementers who wish to track this library against
1515
a different Unicode version may use this tool to manually generate a
1616
different version of the `idnadata.py` and `uts46data.py` files.
1717

@@ -21,7 +21,7 @@ three main modes:
2121

2222
* `idna-data U+0061`. Prints debugging output on the various
2323
properties associated with an individual Unicode codepoint (in this
24-
case, U+0061), that are used to assess the IDNA and UTS 46 status of a
24+
case, U+0061), that are used to assess the IDNA and UTS #46 status of a
2525
codepoint. This is helpful in debugging or analysis.
2626

2727
The tool accepts a number of arguments, described using `idna-data -h`.

0 commit comments

Comments
 (0)