saghul / pycares

Python interface for c-ares
https://pypi.org/project/pycares/
MIT License
162 stars 74 forks source link

4.2.2: pytest is failing in two units #178

Closed kloczek closed 1 year ago

kloczek commented 1 year ago

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

Here is pytest output:

```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pycares-4.2.2-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pycares-4.2.2-2.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra tests/tests.py =========================================================================== test session starts ============================================================================ platform linux -- Python 3.8.16, pytest-7.2.0, pluggy-1.0.0 rootdir: /home/tkloczko/rpmbuild/BUILD/pycares-pycares-4.2.2 collected 54 items tests/tests.py ..................xx.........s.............F...x.Fxs.. [100%] ================================================================================= FAILURES ================================================================================= __________________________________________________________________________ DNSTest.test_query_srv __________________________________________________________________________ self = def test_query_srv(self): self.result, self.errorno = None, None def cb(result, errorno): self.result, self.errorno = result, errorno self.channel.query('_xmpp-server._tcp.google.com', pycares.QUERY_TYPE_SRV, cb) self.wait() > self.assertNoError(self.errorno) tests/tests.py:394: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/tests.py:42: in assertNoError self.assertEqual(errorno, None) E AssertionError: 4 != None _________________________________________________________________ DNSTest.test_query_txt_multiple_chunked __________________________________________________________________ self = def test_query_txt_multiple_chunked(self): self.result, self.errorno = None, None def cb(result, errorno): self.result, self.errorno = result, errorno self.channel.query('google.com', pycares.QUERY_TYPE_TXT, cb) self.wait() self.assertNoError(self.errorno) # > dig -t txt google.com # google.com. 3270 IN TXT "google-site-verification=TV9-DBe4R80X4v0M4U_bd_J9cpOJM0nikft0jAgjmsQ" # google.com. 3270 IN TXT "atlassian-domain-verification=5YjTmWmjI92ewqkx2oXmBaD60Td9zWon9r6eakvHX6B77zzkFQto8PQ9QsKnbf4I" # google.com. 3270 IN TXT "docusign=05958488-4752-4ef2-95eb-aa7ba8a3bd0e" # google.com. 3270 IN TXT "facebook-domain-verification=22rm551cu4k0ab0bxsw536tlds4h95" # google.com. 3270 IN TXT "google-site-verification=wD8N7i1JTNTkezJ49swvWW48f8_9xveREV4oB-0Hf5o" # google.com. 3270 IN TXT "apple-domain-verification=30afIBcvSuDV2PLX" # google.com. 3270 IN TXT "webexdomainverification.8YX6G=6e6922db-e3e6-4a36-904e-a805c28087fa" # google.com. 3270 IN TXT "MS=E4A68B9AB2BB9670BCE15412F62916164C0B20BB" # google.com. 3270 IN TXT "v=spf1 include:_spf.google.com ~all" # google.com. 3270 IN TXT "globalsign-smime-dv=CDYX+XFHUw2wml6/Gb8+59BsH31KzUr6c1l2BPvqKX8=" # google.com. 3270 IN TXT "docusign=1b0a6754-49b1-4db5-8540-d2c12664b289" > self.assertEqual(len(self.result), 11) E AssertionError: 12 != 11 tests/tests.py:314: AssertionError ========================================================================= short test summary info ========================================================================== SKIPPED [1] tests/tests.py:430: ANY type does not work on Mac. SKIPPED [1] tests/tests.py:537: The site used for this test no longer returns a non-ascii SOA. XFAIL tests/tests.py::DNSTest::test_getnameinfo_ipv6 - reason: XFAIL tests/tests.py::DNSTest::test_getnameinfo_ipv6_ll - reason: XFAIL tests/tests.py::DNSTest::test_query_txt_bytes2 - reason: XFAIL tests/tests.py::DNSTest::test_query_txt_multiple_chunked_with_non_ascii_content - reason: FAILED tests/tests.py::DNSTest::test_query_srv - AssertionError: 4 != None FAILED tests/tests.py::DNSTest::test_query_txt_multiple_chunked - AssertionError: 12 != 11 =========================================================== 2 failed, 46 passed, 2 skipped, 4 xfailed in 13.29s ============================================================ ```

Here is list of installed modules in build env

```console Package Version ----------------------------- ----------------- alabaster 0.7.12 apeye 1.2.0 appdirs 1.4.4 attrs 22.1.0 Babel 2.11.0 Brlapi 0.8.3 build 0.9.0 cffi 1.15.1 charset-normalizer 3.0.1 click 8.1.3 contourpy 1.0.6 cssselect 1.1.0 cycler 0.11.0 deprecation 2.1.0 deprecation-alias 0.3.1 dist-meta 0.6.0 distro 1.8.0 dnspython 2.2.1 docutils 0.19 dom_toml 0.6.0 domdf-python-tools 3.3.0 exceptiongroup 1.0.0 extras 1.0.0 fixtures 4.0.0 fonttools 4.38.0 gpg 1.17.1-unknown handy-archives 0.1.2 idna 3.4 imagesize 1.4.1 importlib-metadata 5.1.0 iniconfig 1.1.1 Jinja2 3.1.2 kiwisolver 1.4.4 libcomps 0.1.19 louis 3.24.0 lxml 4.9.1 MarkupSafe 2.1.1 matplotlib 3.6.2 mistletoe 0.9.0 natsort 8.0.2 numpy 1.23.1 olefile 0.46 packaging 21.3 pbr 5.9.0 pep517 0.13.0 Pillow 9.3.0 pip 22.3.1 platformdirs 2.5.2 pluggy 1.0.0 ply 3.11 pycparser 2.21 Pygments 2.13.0 PyGObject 3.42.2 pyparsing 3.0.9 pytest 7.2.0 python-dateutil 2.8.2 pytz 2022.4 requests 2.28.1 rpm 4.17.0 scour 0.38.2 setuptools 65.6.3 shippinglabel 1.4.1 six 1.16.0 snowballstemmer 2.2.0 Sphinx 5.3.0 sphinx-rtd-theme 1.1.1 sphinxcontrib-applehelp 1.0.2.dev20221204 sphinxcontrib-devhelp 1.0.2.dev20221204 sphinxcontrib-htmlhelp 2.0.0 sphinxcontrib-jsmath 1.0.1.dev20221204 sphinxcontrib-qthelp 1.0.3.dev20221204 sphinxcontrib-serializinghtml 1.1.5 testtools 2.5.0 toml 0.10.2 tomli 2.0.1 typing_extensions 4.4.0 urllib3 1.26.12 wheel 0.38.4 zipp 3.11.0 ```
kloczek commented 1 year ago

BTW .. pytest by default scans tests_*py files so it would be good to change name of the tests/tests.py to allow automatically find units.

saghul commented 1 year ago
self.channel.query('_xmpp-server._tcp.google.com', pycares.QUERY_TYPE_SRV, cb)

This one can be fixed by changing the test to _xmpp-server._tcp.jabber.org

self.assertEqual(len(self.result), 11)

This can be fixed by changing the assert to check if the length is > 10.

Would you be interested in making a PR with the changes?

kloczek commented 1 year ago

Sorry I'm busy right now fixing many other rpm packages however if you will create such PR I can quickly plug it into my build procedure to test it 😋

saghul commented 1 year ago

Fixed in #180

kloczek commented 1 year ago

It would be good as well to rename that file to tests_.py to allow pytest automatically scan that file.

kloczek commented 1 year ago

Just tested that commit and now all looks good. Thank you 👍

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pycares-4.2.2-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pycares-4.2.2-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra tests/tests.py
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.16, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pycares-pycares-4.2.2
collected 54 items

tests/tests.py ..................xx.........s.................x..xs..                                                                                                [100%]

========================================================================= short test summary info ==========================================================================
SKIPPED [1] tests/tests.py:430: ANY type does not work on Mac.
SKIPPED [1] tests/tests.py:537: The site used for this test no longer returns a non-ascii SOA.
XFAIL tests/tests.py::DNSTest::test_getnameinfo_ipv6 - reason:
XFAIL tests/tests.py::DNSTest::test_getnameinfo_ipv6_ll - reason:
XFAIL tests/tests.py::DNSTest::test_query_txt_bytes2 - reason:
XFAIL tests/tests.py::DNSTest::test_query_txt_multiple_chunked_with_non_ascii_content - reason:
================================================================ 48 passed, 2 skipped, 4 xfailed in 13.27s =================================================================
kloczek commented 1 year ago

Just tested 4.3.0 and now pytest is able to find units

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pycares-4.3.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pycares-4.3.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.16, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pycares-pycares-4.3.0
collected 54 items

tests/test_all.py ..................xx.........s.................x..xs..                                                                                             [100%]

========================================================================= short test summary info ==========================================================================
SKIPPED [1] tests/test_all.py:430: ANY type does not work on Mac.
SKIPPED [1] tests/test_all.py:537: The site used for this test no longer returns a non-ascii SOA.
XFAIL tests/test_all.py::DNSTest::test_getnameinfo_ipv6 - reason:
XFAIL tests/test_all.py::DNSTest::test_getnameinfo_ipv6_ll - reason:
XFAIL tests/test_all.py::DNSTest::test_query_txt_bytes2 - reason:
XFAIL tests/test_all.py::DNSTest::test_query_txt_multiple_chunked_with_non_ascii_content - reason:
================================================================ 48 passed, 2 skipped, 4 xfailed in 13.33s =================================================================

Thank you 👍

saghul commented 1 year ago

Glad to hear that!