khal: Test failures in 0.9.6

Building khal 0.9.6 in GNU Guix, these tests related to reading from stdin fail for me:

=================================== FAILURES ===================================
____________________________ test_import_from_stdin ____________________________

runner = <tests.cli_test.CustomCliRunner object at 0x7fffef9f3ef0>

    def test_import_from_stdin(runner):
        ics_data = 'This is some really fake icalendar data'
    
        with mock.patch('khal.controllers.import_ics') as mocked_import:
            runner = runner()
            result = runner.invoke(main_khal, ['import'], input=ics_data)
    
>       assert not result.exception
E       AssertionError: assert not OSError(6, 'No such device or address')
E        +  where OSError(6, 'No such device or address') = <Result OSError(6, 'No such device or address')>.exception

tests/cli_test.py:505: AssertionError
________________________ test_printics_read_from_stdin _________________________

runner = <tests.cli_test.CustomCliRunner object at 0x7fffeedfdb00>

    def test_printics_read_from_stdin(runner):
        runner = runner(command='printics')
        result = runner.invoke(main_khal, ['printics'], input=_get_text('cal_d'))
>       assert not result.exception
E       AssertionError: assert not OSError(6, 'No such device or address')
E        +  where OSError(6, 'No such device or address') = <Result OSError(6, 'No such device or address')>.exception

tests/cli_test.py:683: AssertionError
=============== 2 failed, 269 passed, 2 xfailed in 61.21 seconds ===============

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 26 (22 by maintainers)

Commits related to this issue

Most upvoted comments

Also, this is the entire exception error: [Errno 6] No such device or address: '/dev/tty'.

This line is the root cause; when not running in a tty (which is true for some of the commentor’s tests environments, as well when running via docker), /dev/tty doesn’t exist) (sorry, BTW, I wrote that!):

Oddly, when researching the cause of this bug, I came across this code, which [I think!] does what we want, but properly:

I can’t promise to look into it soon though, so help yourselves! 🙂

I’ve managed to reproduce these failures, when running tests inside docker. My current guess is that click’s stdin mocking somehow fails on non scenarios without real ttys. Not sure why that would work on Travis though.

Put this into a Dockerfile in the repo:

FROM python:3.6-stretch

COPY ./ /khal/
WORKDIR /khal/

# These interfere with pytest's scanning, etc:
RUN find . -iname "*.pyc" -delete
# We actually didn't want to copy this over:
RUN rm -rf .tox

RUN pip install tox
RUN tox -e py36

And run docker build ..

At least this makes the issue reproducible, but I’m mostly guessing about the cause.