neithere / argh

An argparse wrapper that doesn't make you say "argh" each time you deal with it.
http://argh.rtfd.org
GNU Lesser General Public License v3.0
369 stars 56 forks source link

0.28.0: pytest fails in `tests/test_completion.py::test_disabled_without_bash` unit #169

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-argh-0.28.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-argh-0.28.0-2.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra -m 'not network' ==================================================================================== test session starts ==================================================================================== platform linux -- Python 3.8.16, pytest-7.2.1, pluggy-1.0.0 rootdir: /home/tkloczko/rpmbuild/BUILD/argh-0.28.0 collected 102 items tests/test_assembling.py ................... [ 18%] tests/test_completion.py .F. [ 21%] tests/test_decorators.py ...... [ 27%] tests/test_dispatching.py ... [ 30%] tests/test_integration.py .......xxx......................................... [ 80%] tests/test_interaction.py ..... [ 85%] tests/test_regressions.py ....... [ 92%] tests/test_utils.py ........ [100%] ========================================================================================= FAILURES ========================================================================================== ________________________________________________________________________________ test_disabled_without_bash _________________________________________________________________________________ mock_logger = , mock_argcomplete = @patch("argh.completion.COMPLETION_ENABLED", False) @patch("argh.completion.argcomplete") @patch("argh.completion.logger") def test_disabled_without_bash(mock_logger, mock_argcomplete): parser = argh.ArghParser() parser.autocomplete() mock_argcomplete.assert_not_called() > mock_logger.debug.assert_not_called() tests/test_completion.py:30: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def assert_not_called(self): """assert that the mock was never called. """ if self.call_count != 0: msg = ("Expected '%s' to not have been called. Called %s times.%s" % (self._mock_name or 'mock', self.call_count, self._calls_repr())) > raise AssertionError(msg) E AssertionError: Expected 'debug' to not have been called. Called 1 times. E Calls: [call('Bash completion is not available. Please install argcomplete.')]. /usr/lib64/python3.8/unittest/mock.py:874: AssertionError ================================================================================== short test summary info ================================================================================== XFAIL tests/test_integration.py::test_simple_function_multiple XFAIL tests/test_integration.py::test_simple_function_nested XFAIL tests/test_integration.py::test_class_method_as_command FAILED tests/test_completion.py::test_disabled_without_bash - AssertionError: Expected 'debug' to not have been called. Called 1 times. ========================================================================== 1 failed, 98 passed, 3 xfailed in 0.54s ========================================================================== ```

Here is list of installed modules in build env

```console Package Version ----------------------------- ----------------- alabaster 0.7.13 appdirs 1.4.4 attrs 22.2.0 Babel 2.11.0 build 0.9.0 charset-normalizer 3.0.1 cssselect 1.1.0 distro 1.8.0 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 gpg 1.18.0-unknown idna 3.4 imagesize 1.4.1 importlib-metadata 6.0.0 iniconfig 2.0.0 iocapture 0.1.2 Jinja2 3.1.2 libcomps 0.1.19 lxml 4.9.2 Markdown 3.4.1 MarkupSafe 2.1.2 mock 4.0.3 natsort 8.0.2 numpy 1.24.2 olefile 0.46 packaging 23.0 pbr 5.9.0 pep517 0.13.0 Pillow 9.4.0 pip 22.3.1 pluggy 1.0.0 Pygments 2.14.0 PyGObject 3.43.1.dev0 pytest 7.2.1 python-dateutil 2.8.2 pytz 2022.4 requests 2.28.2 rpm 4.17.0 scour 0.38.2 six 1.16.0 smartypants 2.0.1 snowballstemmer 2.2.0 Sphinx 6.1.3 sphinx-pyproject 0.1.0 sphinxcontrib-applehelp 1.0.2.dev20221204 sphinxcontrib-devhelp 1.0.2.dev20230202 sphinxcontrib-htmlhelp 2.0.0 sphinxcontrib-jsmath 1.0.1.dev20230128 sphinxcontrib-qthelp 1.0.3.dev20230128 sphinxcontrib-serializinghtml 1.1.5 testtools 2.5.0 toml 0.10.2 tomli 2.0.1 typing_extensions 4.4.0 typogrify 2.0.7 urllib3 1.26.12 wheel 0.38.4 zipp 3.13.0 ```
neithere commented 1 year ago

Hmm, interesting. It's a new test for the old behaviour. I'll look into this tomorrow and let you know if I can repro and fix it. Thank you!

neithere commented 1 year ago

I believe it's fixed in v.0.28.1.

kloczek commented 1 year ago

Just tested new version and all looks good 😄

+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.8.16, pytest-7.2.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/argh-0.28.1
collected 102 items

tests/test_assembling.py ...................                             [ 18%]
tests/test_completion.py ...                                             [ 21%]
tests/test_decorators.py ......                                          [ 27%]
tests/test_dispatching.py ...                                            [ 30%]
tests/test_integration.py .......xxx.................................... [ 75%]
.....                                                                    [ 80%]
tests/test_interaction.py .....                                          [ 85%]
tests/test_regressions.py .......                                        [ 92%]
tests/test_utils.py ........                                             [100%]

=========================== short test summary info ============================
XFAIL tests/test_integration.py::test_simple_function_multiple
XFAIL tests/test_integration.py::test_simple_function_nested
XFAIL tests/test_integration.py::test_class_method_as_command
======================== 99 passed, 3 xfailed in 0.42s =========================

Thank you 👍