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
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python 3.14
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.10"
python-version: "3.14"
- name: Linter and code format verification
run: |
pip install -r requirements-dev.txt
Expand All @@ -36,9 +36,9 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Run tests
Expand All @@ -55,9 +55,9 @@ jobs:
id-token: write # IMPORTANT: mandatory for trusted publishing
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.11
- name: Install pypa/build
Expand All @@ -72,4 +72,4 @@ jobs:
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
github.actor == github.repository_owner
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ setup: clean
)

format:
black hookdns tests
black hookdns tests --target-version py39

lint:
black --check hookdns tests
black --check hookdns tests --target-version py39
flake8 hookdns tests

typing:
Expand Down
1 change: 0 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

import http.server
import socketserver
Expand Down
3 changes: 1 addition & 2 deletions hookdns/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from hookdns.hosts import hosts

__version__ = "2.0.1"
__version__ = "2.0.2"

__all__ = ["hosts"]
1 change: 0 additions & 1 deletion hookdns/getaddrinfo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import contextlib
from typing import Dict
from typing import Generator
Expand Down
1 change: 0 additions & 1 deletion hookdns/gethostbyname.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import contextlib
from typing import Dict
from typing import Generator
Expand Down
3 changes: 1 addition & 2 deletions hookdns/gethostbyname_ex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import contextlib
from typing import Dict
from typing import Generator
Expand Down Expand Up @@ -45,7 +44,7 @@ def _patch_socket_gethostbyname_ex(
hostname: str,
) -> Tuple[str, List[str], List[str]]:
new_host = hosts.get(hostname, hostname)
(_, _, ipaddrlist) = real_socket_gethostbyname_ex(new_host)
_, _, ipaddrlist = real_socket_gethostbyname_ex(new_host)
# we modify the return value with the original hostname
# and set an empty aliaslist
return (hostname, [], ipaddrlist)
Expand Down
1 change: 0 additions & 1 deletion hookdns/hosts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import contextlib
from typing import Dict
from typing import Generator
Expand Down
1 change: 0 additions & 1 deletion tests/test_cm_reentrant.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import requests

from hookdns import hosts
Expand Down
2 changes: 0 additions & 2 deletions tests/test_getaddrinfo.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# -*- coding: utf-8 -*-
import platform
import socket

import pytest

from hookdns.getaddrinfo import patch_getaddrinfo


# tests for the real getaddrinfo


Expand Down
3 changes: 0 additions & 3 deletions tests/test_gethostbyname.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# -*- coding: utf-8 -*-

import socket

import pytest

from hookdns.gethostbyname import patch_gethostbyname


# tests for the real gethostbyname


Expand Down
17 changes: 7 additions & 10 deletions tests/test_gethostbyname_ex.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# -*- coding: utf-8 -*-

import socket

import pytest

from hookdns.gethostbyname_ex import patch_gethostbyname_ex


# tests for the real gethostbyname_ex


def test_real_gethostbyname_ex_with_name():
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("localhost")
hostname, _, ipaddrlist = socket.gethostbyname_ex("localhost")
assert "127.0.0.1" in ipaddrlist


Expand All @@ -20,7 +17,7 @@ def test_real_gethostbyname_ex_with_ip():


def test_real_gethostbyname_ex_with_public_fqdn():
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("example.org")
hostname, _, ipaddrlist = socket.gethostbyname_ex("example.org")
assert hostname == "example.org"
assert len(ipaddrlist) > 0
assert "127.0.0.1" not in ipaddrlist
Expand All @@ -36,7 +33,7 @@ def test_real_gethostbyname_ex_with_unknown_hostname():

@patch_gethostbyname_ex({"localhost": "1.2.3.4"})
def test_patch_decorator_with_name():
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("localhost")
hostname, _, ipaddrlist = socket.gethostbyname_ex("localhost")
assert hostname == "localhost"
assert ipaddrlist == ["1.2.3.4"]

Expand All @@ -48,14 +45,14 @@ def test_patch_decorator_with_ip():

@patch_gethostbyname_ex({"example.org": "1.2.3.4"})
def test_patch_decorator_with_public_fqdn():
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("example.org")
hostname, _, ipaddrlist = socket.gethostbyname_ex("example.org")
assert hostname == "example.org"
assert ipaddrlist == ["1.2.3.4"]


@patch_gethostbyname_ex({"example.org": "localhost"})
def test_patch_decorator_with_public_fqdn_and_a_name_for_addr():
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("example.org")
hostname, _, ipaddrlist = socket.gethostbyname_ex("example.org")
assert hostname == "example.org"
assert "127.0.0.1" in ipaddrlist

Expand All @@ -74,7 +71,7 @@ def test_patch_decorator_with_unknown_hostname():

def test_patch_contextmanager_with_name():
with patch_gethostbyname_ex({"localhost": "1.2.3.4"}):
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("localhost")
hostname, _, ipaddrlist = socket.gethostbyname_ex("localhost")
assert hostname == "localhost"
assert ipaddrlist == ["1.2.3.4"]

Expand All @@ -95,7 +92,7 @@ def test_patch_contextmanager_with_public_fqdn():

def test_patch_contextmanager_with_public_fqdn_and_a_name_for_addr():
with patch_gethostbyname_ex({"example.org": "localhost"}):
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("example.org")
hostname, _, ipaddrlist = socket.gethostbyname_ex("example.org")
assert hostname == "example.org"
assert "127.0.0.1" in ipaddrlist

Expand Down
2 changes: 0 additions & 2 deletions tests/test_hosts_getaddrinfo.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# -*- coding: utf-8 -*-
import platform
import socket

import pytest

from hookdns import hosts


# tests for the real getaddrinfo


Expand Down
3 changes: 0 additions & 3 deletions tests/test_hosts_gethostbyname.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# -*- coding: utf-8 -*-

import socket

import pytest

from hookdns import hosts


# tests for the real gethostbyname


Expand Down
19 changes: 8 additions & 11 deletions tests/test_hosts_gethostbyname_ex.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# -*- coding: utf-8 -*-

import socket

import pytest

from hookdns import hosts


# tests for the real gethostbyname_ex


def test_real_gethostbyname_ex_with_name():
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("localhost")
hostname, _, ipaddrlist = socket.gethostbyname_ex("localhost")
assert "127.0.0.1" in ipaddrlist


Expand All @@ -20,7 +17,7 @@ def test_real_gethostbyname_ex_with_ip():


def test_real_gethostbyname_ex_with_public_fqdn():
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("example.org")
hostname, _, ipaddrlist = socket.gethostbyname_ex("example.org")
assert hostname == "example.org"
assert len(ipaddrlist) > 0
assert "127.0.0.1" not in ipaddrlist
Expand All @@ -36,28 +33,28 @@ def test_real_gethostbyname_ex_with_unknown_hostname():

@hosts({"localhost": "1.2.3.4"})
def test_patch_decorator_with_name():
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("localhost")
hostname, _, ipaddrlist = socket.gethostbyname_ex("localhost")
assert hostname == "localhost"
assert ipaddrlist == ["1.2.3.4"]


@hosts({"127.0.0.1": "1.2.3.4"})
def test_patch_decorator_with_ip():
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("127.0.0.1")
hostname, _, ipaddrlist = socket.gethostbyname_ex("127.0.0.1")
assert hostname == "127.0.0.1"
assert ipaddrlist == ["1.2.3.4"]


@hosts({"example.org": "1.2.3.4"})
def test_patch_decorator_with_public_fqdn():
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("example.org")
hostname, _, ipaddrlist = socket.gethostbyname_ex("example.org")
assert hostname == "example.org"
assert ipaddrlist == ["1.2.3.4"]


@hosts({"example.org": "localhost"})
def test_patch_decorator_with_public_fqdn_and_a_name_for_addr():
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("example.org")
hostname, _, ipaddrlist = socket.gethostbyname_ex("example.org")
assert hostname == "example.org"
assert "127.0.0.1" in ipaddrlist

Expand All @@ -76,7 +73,7 @@ def test_patch_decorator_with_unknown_hostname():

def test_patch_contextmanager_with_name():
with hosts({"localhost": "1.2.3.4"}):
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("localhost")
hostname, _, ipaddrlist = socket.gethostbyname_ex("localhost")
assert hostname == "localhost"
assert ipaddrlist == ["1.2.3.4"]

Expand All @@ -97,7 +94,7 @@ def test_patch_contextmanager_with_public_fqdn():

def test_patch_contextmanager_with_public_fqdn_and_a_name_for_addr():
with hosts({"example.org": "localhost"}):
(hostname, _, ipaddrlist) = socket.gethostbyname_ex("example.org")
hostname, _, ipaddrlist = socket.gethostbyname_ex("example.org")
assert hostname == "example.org"
assert "127.0.0.1" in ipaddrlist

Expand Down
2 changes: 0 additions & 2 deletions tests/test_hosts_requests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

import pytest
import requests

Expand Down
2 changes: 0 additions & 2 deletions tests/test_hosts_requests_session.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

import pytest
import requests

Expand Down