From 68882a9faf906139a05354633f82c2c4831519ff Mon Sep 17 00:00:00 2001 From: Kevin Tindall Date: Tue, 1 Jun 2021 11:12:08 -0500 Subject: [PATCH] Use newer version of dnspython Fixes #132 --- README.md | 2 +- mcstatus/server.py | 4 ++-- mcstatus/tests/test_server.py | 18 +++++++++--------- requirements.txt | 2 +- setup.py | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 7edb2fb..6138a12 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![travis build status]( https://img.shields.io/travis/Dinnerbone/mcstatus/master.svg) +![travis build status](https://img.shields.io/travis/Dinnerbone/mcstatus/master.svg) ![current version](https://img.shields.io/pypi/v/mcstatus.svg) ![supported python versions](https://img.shields.io/pypi/pyversions/mcstatus.svg) diff --git a/mcstatus/server.py b/mcstatus/server.py index ac4d09e..7998083 100644 --- a/mcstatus/server.py +++ b/mcstatus/server.py @@ -37,7 +37,7 @@ def lookup(address: str): if port is None: port = 25565 try: - answers = dns.resolver.query("_minecraft._tcp." + host, "SRV") + answers = dns.resolver.resolve("_minecraft._tcp." + host, "SRV") if len(answers): answer = answers[0] host = str(answer.target).rstrip(".") @@ -148,7 +148,7 @@ def query(self, tries: int = 3): exception = None host = self.host try: - answers = dns.resolver.query(host, "A") + answers = dns.resolver.resolve(host, "A") if len(answers): answer = answers[0] host = str(answer).rstrip(".") diff --git a/mcstatus/tests/test_server.py b/mcstatus/tests/test_server.py index 4a8db1a..be8b89a 100644 --- a/mcstatus/tests/test_server.py +++ b/mcstatus/tests/test_server.py @@ -161,29 +161,29 @@ def test_query_retry(self): assert querier.call_count == 3 def test_by_address_no_srv(self): - with patch("dns.resolver.query") as query: - query.return_value = [] + with patch("dns.resolver.resolve") as resolve: + resolve.return_value = [] self.server = MinecraftServer.lookup("example.org") - query.assert_called_once_with("_minecraft._tcp.example.org", "SRV") + resolve.assert_called_once_with("_minecraft._tcp.example.org", "SRV") assert self.server.host == "example.org" assert self.server.port == 25565 def test_by_address_invalid_srv(self): - with patch("dns.resolver.query") as query: - query.side_effect = [Exception] + with patch("dns.resolver.resolve") as resolve: + resolve.side_effect = [Exception] self.server = MinecraftServer.lookup("example.org") - query.assert_called_once_with("_minecraft._tcp.example.org", "SRV") + resolve.assert_called_once_with("_minecraft._tcp.example.org", "SRV") assert self.server.host == "example.org" assert self.server.port == 25565 def test_by_address_with_srv(self): - with patch("dns.resolver.query") as query: + with patch("dns.resolver.resolve") as resolve: answer = Mock() answer.target = "different.example.org." answer.port = 12345 - query.return_value = [answer] + resolve.return_value = [answer] self.server = MinecraftServer.lookup("example.org") - query.assert_called_once_with("_minecraft._tcp.example.org", "SRV") + resolve.assert_called_once_with("_minecraft._tcp.example.org", "SRV") assert self.server.host == "different.example.org" assert self.server.port == 12345 diff --git a/requirements.txt b/requirements.txt index 9098b17..44c985e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ asyncio-dgram>=1.2.0 click>=7.1.1 -dnspython3>=1.15.0 +dnspython>=2.1.0 six>=1.14.0 diff --git a/setup.py b/setup.py index afb3f1c..e1346a1 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name="mcstatus", - version="5.2.0", + version="6.0.0", author="Nathan Adams", author_email="dinnerbone@dinnerbone.com", url="https://pypi.python.org/pypi/mcstatus",