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 docs/source/pcapkit/const/linux.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Available enumerations include:

.. list-table::

* - :class:`ARPHRD <pcapkit.const.linux.arphrd.ARPHRD>`
* - :class:`Linux_ARPHRD <pcapkit.const.linux.arphrd.ARPHRD>`
- Linux ARP Hardware Types [*]_

ARP Hardware Types
Expand Down
3 changes: 3 additions & 0 deletions pcapkit/const/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from pcapkit.const.ipv6 import *
from pcapkit.const.ipx import *
from pcapkit.const.l2tp import *
from pcapkit.const.linux import *
from pcapkit.const.mh import *
from pcapkit.const.ngap import *
from pcapkit.const.ospf import *
Expand Down Expand Up @@ -78,6 +79,8 @@
'IPX_Packet', 'IPX_Socket',
# L2TP
'L2TP_Type',
# Linux
'Linux_ARPHRD',
# MH
'MH_Packet', 'MH_Option', 'MH_DNSStatusCode', 'MH_ACKStatusCode',
'MH_MNIDSubtype', 'MH_StatusCode', 'MH_EnumeratingAlgorithm',
Expand Down
6 changes: 3 additions & 3 deletions pcapkit/const/linux/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

.. list-table::

* - :class:`ARPHRD <pcapkit.const.linux.arphrd.ARPHRD>`
* - :class:`Linux_ARPHRD <pcapkit.const.linux.arphrd.ARPHRD>`
- Linux ARP Hardware Types

"""

from pcapkit.const.linux.arphrd import ARPHRD
from pcapkit.const.linux.arphrd import ARPHRD as Linux_ARPHRD

__all__ = ['ARPHRD']
__all__ = ['Linux_ARPHRD']
51 changes: 51 additions & 0 deletions tests/const/test_const_linux_export_2661_unit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
"""Unit tests for the :mod:`pcapkit.const.linux` package surface (#2661).

Every other package of :mod:`pcapkit.const` re-exports its registries under a
package prefix, and :mod:`pcapkit.const` star-imports each package so the names
reach its own ``__all__``. The Linux package did neither, and
:mod:`pcapkit.vendor.linux` already exports its crawler as ``Linux_ARPHRD``.

"""
from __future__ import annotations

import unittest

#: Test tier (#1958): pure-Python attribute lookups, which behave the same on
#: every interpreter.
__tier__ = 'LATEST'


class LinuxConstSurfaceTests(unittest.TestCase):
""":mod:`pcapkit.const.linux` and its place in :mod:`pcapkit.const`."""

def test_package_exports_the_registry_under_a_package_prefix(self) -> None:
import pcapkit.const.linux
from pcapkit.const.linux.arphrd import ARPHRD

self.assertEqual(pcapkit.const.linux.__all__, ['Linux_ARPHRD'])
self.assertIs(pcapkit.const.linux.Linux_ARPHRD, ARPHRD)

def test_const_package_re_exports_the_registry(self) -> None:
import pcapkit.const
from pcapkit.const.linux.arphrd import ARPHRD

self.assertIn('Linux_ARPHRD', pcapkit.const.__all__)
self.assertIs(pcapkit.const.Linux_ARPHRD, ARPHRD)

def test_star_import_of_const_binds_the_registry(self) -> None:
from pcapkit.const.linux.arphrd import ARPHRD

namespace = {} # type: dict[str, object]
exec('from pcapkit.const import *', namespace) # pylint: disable=exec-used
self.assertIs(namespace['Linux_ARPHRD'], ARPHRD)

def test_names_pair_with_the_vendor_crawler(self) -> None:
import pcapkit.const.linux
import pcapkit.vendor.linux

self.assertEqual(pcapkit.const.linux.__all__, pcapkit.vendor.linux.__all__)


if __name__ == '__main__':
unittest.main()
10 changes: 3 additions & 7 deletions tests/project/test_const_package_exports_2656_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,9 @@
}

#: Registry packages of :mod:`pcapkit.const` that :file:`pcapkit/const/__init__.py` does not
#: re-export, a recorded defect (#2661). Each reason names what is missing. Wiring a package
#: deletes its entry, which ``test_unwired_entries_hold`` enforces.
KNOWN_UNWIRED = {
'linux': 'no "from pcapkit.const.linux import *" in pcapkit/const/__init__.py, and the name '
'is unprefixed: pcapkit.const.linux.__all__ lists ARPHRD, where the house prefix '
'gives Linux_ARPHRD, as pcapkit.vendor.linux.__all__ lists it',
}
#: re-export, a recorded defect. Each reason names what is missing and the issue that tracks
#: it. Wiring a package deletes its entry, which ``test_unwired_entries_hold`` enforces.
KNOWN_UNWIRED = {} # type: dict[str, str]

#: A ``.. toctree::`` directive, capturing its indentation.
TOCTREE = re.compile(r'^(\s*)\.\. toctree::\s*$')
Expand Down
Loading