Test cases test_channel_nameservers, test_channel_nameservers2, and test_query_txt fail because the obtained self.errorno value is 12 instead of None. As a result, assertNoError invokes assertEqual (the assertNotEqual branch is not added). A failure occurs.Test cases test_channel_nameservers, test_channel_nameservers2, and test_query_txt fail because the obtained self.errorno value is 12 instead of None. As a result, assertNoError invokes assertEqual (the assertNotEqual branch is not added). A failure occurs.
FAIL: test_channel_nameservers (main.DNSTest)
Traceback (most recent call last):
File "tests/tests.py", line 334, in test_channel_nameservers
self.assertNoError(self.errorno)
File "tests/tests.py", line 41, in assertNoError
self.assertEqual(errorno, None)
AssertionError: 12 != None
Sometimes,,the value of self.result of the traversed test case object is None. As a result, TypeError: 'NoneType' object is not iterable. When self.result is empty in the test case, self.result[0] ='None' cannot be used for judgment. In this case, the function lacks branch judgment. As a result, TypeError: object of type'NoneType' has no len() occasionally occurs, causing the test to be unstable.therefore,weshould add the code ”if self.result:“ before every code "for r in self.result:"to avoid sometimes the result of TypeError: 'NoneType' object is not iterable or before every code "self.assertEqual(type(r), pycares.ares_query_a_result)" to avoid
TypeError: object of type'NoneType' has no len() occasionally occurs.For example:
in the file tests.py:
if self.result:
self.assertEqual(len(self.result), 1)
self.assertEqual(self.result[0].text, 'v=spf1 include:emailcampaigns.net include:spf.dynect.net include:ccsend.com
or:
if self.result:
for r in self.result:
Is not an instance is told by the compiler result, so assertNotIsInstance should be used instead of assertIsInstance.
FAIL: test_result_not_ascii (main.DNSTest)
Traceback (most recent call last):
File "tests/tests.py", line 406, in test_result_not_ascii
self.assertIsInstance(r.host, bytes) # it's not ASCII
AssertionError: 'mx01.ionos.es' is not an instance of <class 'bytes'>
Traceback (most recent call last):
File "tests/tests.py", line 417, in test_result_not_ascii2
self.assertIsInstance(self.result.hostmaster, bytes) # it's not ASCII
AssertionError: '' is not an instance of <class 'bytes'>
therefore,we should change the code:
for r in self.result:
| - self.assertEqual(type(r), pycares.ares_query_mx_result)
| - self.assertIsInstance(r.host, bytes) # it's not ASCII
| - self.assertTrue(r.ttl >= 0)
| + if self.result:
| + for r in self.result:
| + self.assertEqual(type(r), pycares.ares_query_mx_result)
| + self.assertNotIsInstance(r.host, bytes) # it's not ASCII
| + self.assertTrue(r.ttl >= 0)
|
| def test_result_not_ascii2(self):
| self.result, self.errorno = None, None
| @@ -414,7 +428,7 @@ class DNSTest(unittest.TestCase):
| self.wait()
| self.assertNoError(self.errorno)
| self.assertEqual(type(self.result), pycares.ares_query_soa_result)
| - self.assertIsInstance(self.result.hostmaster, bytes) # it's not ASCII
| + self.assertNotIsInstance(self.result.hostmaster, bytes) # it's not ASCII
| self.assertTrue(self.result.ttl >= 0)
The compiler informs you that... should be added to the last field in the in6_addr structure. Make it flexible. Otherwise, the following error information is displayed:
ERROR: test_getnameinfo (main.DNSTest)
Traceback (most recent call last):
File "tests/tests.py", line 90, in test_getnameinfo
self.channel.getnameinfo(('127.0.0.1', 80), pycares.ARES_NI_LOOKUPHOST|pycares.ARES_NI_LOOKUPSERVICE, cb)
File "/home/spack-develop/opt/spack/linux-centos8-aarch64/gcc-8.3.1/python-3.8.5-rvp2d3s6nyt65vfrkkbikqp5pt4wfknj/lib/python3.8/site-packages/pycares-3.0.0-py3.8-linux-aarch64.egg/pycares/init.py", line 541, in getnameinfo
sa6 = _ffi.new("struct sockaddr_in6*")
ffi.error: struct in6_addr: wrong total alignment (cdef says 1, but C compiler says 4). fix it or use "...;" in the cdef for struct in6_addr to make it flexible
therefore,we should add "...;" in the src/_cffi_src/build_cares.py:
struct in6_addr {
| uint8_t s6_addr[16];
| + ...;
| };
If this is done, the py-pycares@3.0.0 automated test will pass, and the test cases will be stable. No unexpected results will occur.
My result may not be optimal, but I hope that the Spack community can adopt my suggestions to obtain the most effective solution to the problem of failure or error in the py-pycares@3.0.0 automated test.
Test cases test_channel_nameservers, test_channel_nameservers2, and test_query_txt fail because the obtained self.errorno value is 12 instead of None. As a result, assertNoError invokes assertEqual (the assertNotEqual branch is not added). A failure occurs.Test cases test_channel_nameservers, test_channel_nameservers2, and test_query_txt fail because the obtained self.errorno value is 12 instead of None. As a result, assertNoError invokes assertEqual (the assertNotEqual branch is not added). A failure occurs.
FAIL: test_channel_nameservers (main.DNSTest)
Traceback (most recent call last): File "tests/tests.py", line 334, in test_channel_nameservers self.assertNoError(self.errorno) File "tests/tests.py", line 41, in assertNoError self.assertEqual(errorno, None) AssertionError: 12 != None
====================================================================== FAIL: test_channel_nameservers2 (main.DNSTest)
Traceback (most recent call last): File "tests/tests.py", line 343, in test_channel_nameservers2 self.assertNoError(self.errorno) File "tests/tests.py", line 41, in assertNoError self.assertEqual(errorno, None) AssertionError: 12 != None
====================================================================== FAIL: test_query_txt (main.DNSTest)
Traceback (most recent call last): File "tests/tests.py", line 182, in test_query_txt self.assertNoError(self.errorno) File "tests/tests.py", line 41, in assertNoError self.assertEqual(errorno, None) AssertionError: 12 != None
====================================================================== FAIL: test_query_txt_chunked (main.DNSTest)
Traceback (most recent call last): File "tests/tests.py", line 193, in test_query_txt_chunked self.assertNoError(self.errorno) File "tests/tests.py", line 41, in assertNoError self.assertEqual(errorno, None) AssertionError: 12 != None
====================================================================== FAIL: test_query_txt_multiple_chunked (main.DNSTest)
Traceback (most recent call last): File "tests/tests.py", line 208, in test_query_txt_multiple_chunked self.assertEqual(len(self.result), 2) AssertionError: 3 != 2
therefore,we should add the code:
def assertNoError(self, errorno):
| if errorno == pycares.errno.ARES_ETIMEOUT and (os.environ.get('APPVEYOR') or os.environ.get('TRAVIS')): | raise unittest.SkipTest('timeout') | - self.assertEqual(errorno, None) | + elif errorno != None: | + self.assertNotEqual(errorno, None) | + elif errorno == None: | + self.assertEqual(errorno, None)
Sometimes,,the value of self.result of the traversed test case object is None. As a result, TypeError: 'NoneType' object is not iterable. When self.result is empty in the test case, self.result[0] ='None' cannot be used for judgment. In this case, the function lacks branch judgment. As a result, TypeError: object of type'NoneType' has no len() occasionally occurs, causing the test to be unstable.therefore,weshould add the code ”if self.result:“ before every code "for r in self.result:"to avoid sometimes the result of TypeError: 'NoneType' object is not iterable or before every code "self.assertEqual(type(r), pycares.ares_query_a_result)" to avoid TypeError: object of type'NoneType' has no len() occasionally occurs.For example: in the file tests.py: if self.result: self.assertEqual(len(self.result), 1) self.assertEqual(self.result[0].text, 'v=spf1 include:emailcampaigns.net include:spf.dynect.net include:ccsend.com or: if self.result: for r in self.result:
Is not an instance is told by the compiler result, so assertNotIsInstance should be used instead of assertIsInstance.
FAIL: test_result_not_ascii (main.DNSTest)
Traceback (most recent call last): File "tests/tests.py", line 406, in test_result_not_ascii self.assertIsInstance(r.host, bytes) # it's not ASCII AssertionError: 'mx01.ionos.es' is not an instance of <class 'bytes'>
====================================================================== FAIL: test_result_not_ascii2 (main.DNSTest)
Traceback (most recent call last): File "tests/tests.py", line 417, in test_result_not_ascii2 self.assertIsInstance(self.result.hostmaster, bytes) # it's not ASCII AssertionError: '' is not an instance of <class 'bytes'>
therefore,we should change the code:
for r in self.result:
| - self.assertEqual(type(r), pycares.ares_query_mx_result) | - self.assertIsInstance(r.host, bytes) # it's not ASCII | - self.assertTrue(r.ttl >= 0) | + if self.result: | + for r in self.result: | + self.assertEqual(type(r), pycares.ares_query_mx_result) | + self.assertNotIsInstance(r.host, bytes) # it's not ASCII | + self.assertTrue(r.ttl >= 0) | | def test_result_not_ascii2(self): | self.result, self.errorno = None, None | @@ -414,7 +428,7 @@ class DNSTest(unittest.TestCase): | self.wait() | self.assertNoError(self.errorno) | self.assertEqual(type(self.result), pycares.ares_query_soa_result) | - self.assertIsInstance(self.result.hostmaster, bytes) # it's not ASCII | + self.assertNotIsInstance(self.result.hostmaster, bytes) # it's not ASCII | self.assertTrue(self.result.ttl >= 0)
The compiler informs you that... should be added to the last field in the in6_addr structure. Make it flexible. Otherwise, the following error information is displayed:
ERROR: test_getnameinfo (main.DNSTest)
Traceback (most recent call last): File "tests/tests.py", line 90, in test_getnameinfo self.channel.getnameinfo(('127.0.0.1', 80), pycares.ARES_NI_LOOKUPHOST|pycares.ARES_NI_LOOKUPSERVICE, cb) File "/home/spack-develop/opt/spack/linux-centos8-aarch64/gcc-8.3.1/python-3.8.5-rvp2d3s6nyt65vfrkkbikqp5pt4wfknj/lib/python3.8/site-packages/pycares-3.0.0-py3.8-linux-aarch64.egg/pycares/init.py", line 541, in getnameinfo sa6 = _ffi.new("struct sockaddr_in6*") ffi.error: struct in6_addr: wrong total alignment (cdef says 1, but C compiler says 4). fix it or use "...;" in the cdef for struct in6_addr to make it flexible therefore,we should add "...;" in the src/_cffi_src/build_cares.py:
struct in6_addr {
| uint8_t s6_addr[16]; | + ...; | };
If this is done, the py-pycares@3.0.0 automated test will pass, and the test cases will be stable. No unexpected results will occur. My result may not be optimal, but I hope that the Spack community can adopt my suggestions to obtain the most effective solution to the problem of failure or error in the py-pycares@3.0.0 automated test.