Rockhopper-Technologies / enlighten

Enlighten Progress Bar for Python Console Apps
https://python-enlighten.readthedocs.io
Mozilla Public License 2.0
416 stars 25 forks source link

9 tests fail #50

Closed yurivict closed 2 years ago

yurivict commented 2 years ago

Describe the bug


========================================================================================== FAILURES ==========================================================================================
___________________________________________________________________________________ TestManager.test_init ____________________________________________________________________________________

self = <tests.test_manager.TestManager testMethod=test_init>

    @unittest.skipIf(STDOUT_NO_FD, 'No file descriptor for stdout')
    def test_init(self):
        # Companion stream is __stderr__ if stream is __stdout__

        # Need to mock isatty() for some build and test environments
        with mock.patch.object(sys, '__stderr__') as mock_stderr:
            mock_stderr.isatty.return_value = True
            manager = enlighten.Manager(stream=sys.__stdout__)

>       self.assertIs(manager.stream, sys.stdout)
E       AssertionError: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> is not <_io.TextIOWrapper name="<_io.FileIO name=6 mode='rb+' closefd=True>" mode='r+' encoding='utf-8'>

tests/test_manager.py:55: AssertionError
___________________________________________________________________________________ TestManager.test_repr ____________________________________________________________________________________

self = <tests.test_manager.TestManager testMethod=test_repr>

    def test_repr(self):
        manager = enlighten.Manager()
>       self.assertEqual(repr(manager), "Manager(stream=%r)" % sys.stdout)
E       AssertionError: "Manager(stream=<_io.TextIOWrapper name='[33 chars]8'>)" != 'Manager(stream=<_io.TextIOWrapper name="[75 chars]\'>)'
E       - Manager(stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)
E       + Manager(stream=<_io.TextIOWrapper name="<_io.FileIO name=6 mode='rb+' closefd=True>" mode='r+' encoding='utf-8'>)

tests/test_manager.py:139: AssertionError
__________________________________________________________________________ TestHTMLConverter.test_class_not_unique ___________________________________________________________________________

self = <tests.test_util.TestHTMLConverter testMethod=test_class_not_unique>

    def test_class_not_unique(self):
        """Repeated classes are dropped within the same span"""

>       out = self.converter.to_html(self.term.blue_on_aquamarine(self.term.blue('blue_on_aquam')))

tests/test_util.py:247: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
enlighten/_util.py:268: in to_html
    normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

.0 = <tuple_iterator object at 0x912d98130>

>   normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
E   TypeError: 'Termcap' object is not subscriptable

enlighten/_util.py:268: TypeError
________________________________________________________________________________ TestHTMLConverter.test_color ________________________________________________________________________________

self = <tests.test_util.TestHTMLConverter testMethod=test_color>

    def test_color(self):
        """Verify color conversion"""

        # CGA color on RGB color
>       out = self.converter.to_html(self.term.blue_on_aquamarine('blue_on_aquam'))

tests/test_util.py:117: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
enlighten/_util.py:268: in to_html
    normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <enlighten._util.Lookahead object at 0x918b28b50>, start = 0, stop = None

    def lookahead(self, start, stop=None):
        """
        Args:
            start(int): Positive integer index of first value
            stop(int): Positive integer index to end before (not returned)

        Retrieve next value(s) in iterator.

        start and stop roughly behave like slice notation, but must be positive
        """

        last = max(start, (stop or 0) - 1)

        while last >= len(self.buffer):
            try:
                self.buffer.append(next(self.iterator))
            except StopIteration:
                break

>       return self.buffer[start] if stop is None else self.buffer[start:stop]
E       IndexError: list index out of range

enlighten/_util.py:163: IndexError
_____________________________________________________________________________ TestHTMLConverter.test_empty_span ______________________________________________________________________________

self = <tests.test_util.TestHTMLConverter testMethod=test_empty_span>

    def test_empty_span(self):
        """Empty Spans are ignored"""

>       out = self.converter.to_html(self.term.underline('') + 'empty')

tests/test_util.py:241: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
enlighten/_util.py:268: in to_html
    normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

.0 = <tuple_iterator object at 0x9191f39d0>

>   normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
E   TypeError: 'NoneType' object is not subscriptable

enlighten/_util.py:268: TypeError
________________________________________________________________________________ TestHTMLConverter.test_style ________________________________________________________________________________

self = <tests.test_util.TestHTMLConverter testMethod=test_style>

    def test_style(self):
        """Verify style conversion"""

        # Italics
>       out = self.converter.to_html(self.term.italic('italic'))

tests/test_util.py:183: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
enlighten/_util.py:268: in to_html
    normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <enlighten._util.Lookahead object at 0x913854b50>, start = 0, stop = None

    def lookahead(self, start, stop=None):
        """
        Args:
            start(int): Positive integer index of first value
            stop(int): Positive integer index to end before (not returned)

        Retrieve next value(s) in iterator.

        start and stop roughly behave like slice notation, but must be positive
        """

        last = max(start, (stop or 0) - 1)

        while last >= len(self.buffer):
            try:
                self.buffer.append(next(self.iterator))
            except StopIteration:
                break

>       return self.buffer[start] if stop is None else self.buffer[start:stop]
E       IndexError: list index out of range

enlighten/_util.py:163: IndexError
____________________________________________________________________________ TestHTMLConverter.test_style_output _____________________________________________________________________________

self = <tests.test_util.TestHTMLConverter testMethod=test_style_output>

    def test_style_output(self):
        """Verify style section output"""

>       out = self.converter.to_html(self.term.red_on_slategrey('red_on_slategrey'))

tests/test_util.py:256: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
enlighten/_util.py:268: in to_html
    normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <enlighten._util.Lookahead object at 0x9191f3100>, start = 0, stop = None

    def lookahead(self, start, stop=None):
        """
        Args:
            start(int): Positive integer index of first value
            stop(int): Positive integer index to end before (not returned)

        Retrieve next value(s) in iterator.

        start and stop roughly behave like slice notation, but must be positive
        """

        last = max(start, (stop or 0) - 1)

        while last >= len(self.buffer):
            try:
                self.buffer.append(next(self.iterator))
            except StopIteration:
                break

>       return self.buffer[start] if stop is None else self.buffer[start:stop]
E       IndexError: list index out of range

enlighten/_util.py:163: IndexError
_______________________________________________________________________ TestHTMLConverter.test_style_output_additional _______________________________________________________________________

self = <tests.test_util.TestHTMLConverter testMethod=test_style_output_additional>

    def test_style_output_additional(self):
        """Verify style section output with additional sections"""

        out = self.converter.to_html(self.term.blink('blink'))
>       self.assertEqual(out, '<pre><span class="enlighten-blink">blink</span></pre>')
E       AssertionError: '<pre>blink</pre>' != '<pre><span class="enlighten-blink">blink</span></pre>'
E       - <pre>blink</pre>
E       + <pre><span class="enlighten-blink">blink</span></pre>

tests/test_util.py:280: AssertionError
_____________________________________________________________________________ TestHTMLConverter.test_unsupported _____________________________________________________________________________

self = <tests.test_util.TestHTMLConverter testMethod=test_unsupported>

    def test_unsupported(self):
        """Verify unsupported does not produce classes"""

        # Unsupported capability
        out = self.converter.to_html(self.term.move(5, 6) + 'unsupported_move')
        self.assertEqual(out, '<pre>unsupported_move</pre>')

        # Unsupported text attribute
>       out = self.converter.to_html(self.term.reverse('unsupported_reverse'))

tests/test_util.py:224: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
enlighten/_util.py:268: in to_html
    normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <enlighten._util.Lookahead object at 0x915b77850>, start = 0, stop = None

    def lookahead(self, start, stop=None):
        """
        Args:
            start(int): Positive integer index of first value
            stop(int): Positive integer index to end before (not returned)

        Retrieve next value(s) in iterator.

        start and stop roughly behave like slice notation, but must be positive
        """

        last = max(start, (stop or 0) - 1)

        while last >= len(self.buffer):
            try:
                self.buffer.append(next(self.iterator))
            except StopIteration:
                break

>       return self.buffer[start] if stop is None else self.buffer[start:stop]
E       IndexError: list index out of range

enlighten/_util.py:163: IndexError
====================================================================================== warnings summary ======================================================================================
../../../../../../usr/local/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191
  /usr/local/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191: DeprecationWarning: The 'asyncio_mode' default value will change to 'strict' in future, please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' in pytest configuration file.
    config.issue_config_time_warning(LEGACY_MODE, stacklevel=2)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ===================================================================================
SKIPPED [1] tests/test_notebook_manager.py:58: Notebook testing packages not installed
==================================================================== 9 failed, 120 passed, 1 skipped, 1 warning in 21.31s ====================================================================

To Reproduce run pytest

Environment (please complete the following information):

avylove commented 2 years ago

Thanks for reporting!

The first two I can reproduce with pytest. I don't use pytest, but the tests should still run clean. You shouldn't see the errors if you use the standard test runner, python -m unittest discover.

The rest look they are related to test_util.TestHTMLConverter. It seems it's at least partially caused because it can't find terminal info for xterm-256color. On Linux, the terminfo data gets installed with ncurses, not sure if it's the same with FreeBSD. On my system it's under /usr/share/terminfo, but the FreeBSD man page says /usr/share/misc/terminfo. Can you see if you can find the files and let me know what xterm variations you have available?

It does look like Lookahead doesn't handle a case where the buffer is empty. Not sure how it's getting to that state, but it should handle it regardless.

avylove commented 2 years ago

First two fixed in af10a76e49d60f461f8dffaa99f008422d8eb46b. Still need to look into the rest.

avylove commented 2 years ago

For TestHTMLConverter, I removed the specific terminal kind in 400233d5cb0b428c915e3b41e37356e065986005. It shouldn't be necessary because styling and number of colors is being forced. We're also not using subprocesses, so the same terminal kind will be used for all tests anyway. For now, we'll just use the default for the environment, but if that becomes an issue we'll need to specify it for all tests.

Still need to look at Lookahead

avylove commented 2 years ago

Refactored Lookahead in 79d6b2023bca181cb7e678156c592659feec4e22 so it takes slice notation. That should avoid that type of IndexError, though it will may rise somewhere else under those conditions.

@yurivict would you mind testing main to see if any of the issues still persist?

yurivict commented 2 years ago
========================================================================================== FAILURES ==========================================================================================
__________________________________________________________________________ TestHTMLConverter.test_class_not_unique ___________________________________________________________________________

self = <tests.test_util.TestHTMLConverter testMethod=test_class_not_unique>

    def test_class_not_unique(self):
        """Repeated classes are dropped within the same span"""

        out = self.converter.to_html(self.term.blue_on_aquamarine(self.term.blue('blue_on_aquam')))
>       self.assertEqual(
            out,
            '<pre><span class="enlighten-fg-blue enlighten-bg-7fffd4">blue_on_aquam</span></pre>'
        )
E       AssertionError: '<pre[19 chars]hten-fg-0000ee enlighten-bg-7fffd4">blue_on_aquam</span></pre>' != '<pre[19 chars]hten-fg-blue enlighten-bg-7fffd4">blue_on_aquam</span></pre>'
E       - <pre><span class="enlighten-fg-0000ee enlighten-bg-7fffd4">blue_on_aquam</span></pre>
E       ?                                ^^^^ -
E       + <pre><span class="enlighten-fg-blue enlighten-bg-7fffd4">blue_on_aquam</span></pre>
E       ?                                ^^^

tests/test_util.py:261: AssertionError
________________________________________________________________________________ TestHTMLConverter.test_color ________________________________________________________________________________

self = <tests.test_util.TestHTMLConverter testMethod=test_color>

    def test_color(self):
        """Verify color conversion"""

        # CGA color on RGB color
        out = self.converter.to_html(self.term.blue_on_aquamarine('blue_on_aquam'))
>       self.assertEqual(
            out,
            '<pre><span class="enlighten-fg-blue enlighten-bg-7fffd4">blue_on_aquam</span></pre>'
        )
E       AssertionError: '<pre[19 chars]hten-fg-0000ee enlighten-bg-7fffd4">blue_on_aquam</span></pre>' != '<pre[19 chars]hten-fg-blue enlighten-bg-7fffd4">blue_on_aquam</span></pre>'
E       - <pre><span class="enlighten-fg-0000ee enlighten-bg-7fffd4">blue_on_aquam</span></pre>
E       ?                                ^^^^ -
E       + <pre><span class="enlighten-fg-blue enlighten-bg-7fffd4">blue_on_aquam</span></pre>
E       ?                                ^^^

tests/test_util.py:131: AssertionError
_____________________________________________________________________________ TestHTMLConverter.test_empty_span ______________________________________________________________________________

self = <tests.test_util.TestHTMLConverter testMethod=test_empty_span>

    def test_empty_span(self):
        """Empty Spans are ignored"""

        out = self.converter.to_html(self.term.underline('') + 'empty')
>       self.assertEqual(out, '<pre>empty</pre>')
E       AssertionError: '<pre><span class="enlighten-underline">empty</span></pre>' != '<pre>empty</pre>'
E       - <pre><span class="enlighten-underline">empty</span></pre>
E       + <pre>empty</pre>

tests/test_util.py:255: AssertionError
________________________________________________________________________________ TestHTMLConverter.test_style ________________________________________________________________________________

self = <tests.test_util.TestHTMLConverter testMethod=test_style>

    def test_style(self):
        """Verify style conversion"""

        # Italics
        out = self.converter.to_html(self.term.italic('italic'))
        self.assertEqual(out, '<pre><span class="enlighten-italic">italic</span></pre>')

        self.assertEqual(self.converter._styles['enlighten-italic'], {'font-style': 'italic'})

        # Bold
        out = self.converter.to_html(self.term.bold('bold'))
        self.assertEqual(out, '<pre><span class="enlighten-bold">bold</span></pre>')

        self.assertEqual(self.converter._styles['enlighten-bold'], {'font-weight': 'bold'})

        # Underline
        out = self.converter.to_html(self.term.underline('underline'))
        self.assertEqual(out, '<pre><span class="enlighten-underline">underline</span></pre>')

        self.assertEqual(
            self.converter._styles['enlighten-underline'], {'text-decoration': 'underline'}
        )

        # Blink
        out = self.converter.to_html(self.term.blink('blink'))
>       self.assertEqual(out, '<pre><span class="enlighten-blink">blink</span></pre>')
E       AssertionError: '<pre>blink</pre>' != '<pre><span class="enlighten-blink">blink</span></pre>'
E       - <pre>blink</pre>
E       + <pre><span class="enlighten-blink">blink</span></pre>

tests/test_util.py:217: AssertionError
____________________________________________________________________________ TestHTMLConverter.test_style_output _____________________________________________________________________________

self = <tests.test_util.TestHTMLConverter testMethod=test_style_output>

    def test_style_output(self):
        """Verify style section output"""

        out = self.converter.to_html(self.term.red_on_slategrey('red_on_slategrey'))

>       self.assertEqual(
            out,
            '<pre><span class="enlighten-fg-red enlighten-bg-708090">red_on_slategrey</span></pre>'
        )
E       AssertionError: '<pre[22 chars]n-fg-cd0000 enlighten-bg-708090">red_on_slategrey</span></pre>' != '<pre[22 chars]n-fg-red enlighten-bg-708090">red_on_slategrey</span></pre>'
E       - <pre><span class="enlighten-fg-cd0000 enlighten-bg-708090">red_on_slategrey</span></pre>
E       ?                                ^ ----
E       + <pre><span class="enlighten-fg-red enlighten-bg-708090">red_on_slategrey</span></pre>
E       ?                                ^^

tests/test_util.py:271: AssertionError
_______________________________________________________________________ TestHTMLConverter.test_style_output_additional _______________________________________________________________________

self = <tests.test_util.TestHTMLConverter testMethod=test_style_output_additional>

    def test_style_output_additional(self):
        """Verify style section output with additional sections"""

        out = self.converter.to_html(self.term.blink('blink'))
>       self.assertEqual(out, '<pre><span class="enlighten-blink">blink</span></pre>')
E       AssertionError: '<pre>blink</pre>' != '<pre><span class="enlighten-blink">blink</span></pre>'
E       - <pre>blink</pre>
E       + <pre><span class="enlighten-blink">blink</span></pre>

tests/test_util.py:293: AssertionError
====================================================================================== warnings summary ======================================================================================
../../../../../../usr/local/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191
  /usr/local/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191: DeprecationWarning: The 'asyncio_mode' default value will change to 'strict' in future, please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' in pytest configuration file.
    config.issue_config_time_warning(LEGACY_MODE, stacklevel=2)

tests/test_util.py::TestHTMLConverter::test_class_not_unique
tests/test_util.py::TestHTMLConverter::test_color
tests/test_util.py::TestHTMLConverter::test_empty_span
tests/test_util.py::TestHTMLConverter::test_style
tests/test_util.py::TestHTMLConverter::test_style_output
tests/test_util.py::TestHTMLConverter::test_style_output_additional
  /usr/local/lib/python3.9/site-packages/pytest_trio/plugin.py:62: TrioDeprecationWarning: trio.MultiError is deprecated since Trio 0.22.0; use BaseExceptionGroup (on Python 3.11 and later) or exceptiongroup.BaseExceptionGroup (earlier versions) instead (https://github.com/python-trio/trio/issues/2211)
    if issubclass(call.excinfo.type, trio.MultiError):

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ===================================================================================
SKIPPED [1] tests/test_notebook_manager.py:58: Notebook testing packages not installed
=================================================================== 6 failed, 124 passed, 1 skipped, 7 warnings in 20.42s ====================================================================
avylove commented 2 years ago

It seems this platform doesn't support some of the formatting escape codes. Looking over the tests, the TERM environment variable is set to xterm-256color before any tests are run. I can get similar, though not exact, failures if I set this to a more limited xterm spec.

Are you seeing anything like:

/lib/python3.9/site-packages/blessed/terminal.py:186: UserWarning: Failed to setupterm(kind='xterm-256color'): setupterm: could not find terminal
avylove commented 2 years ago

I spun up a VM and got the same output as you. It looks like this is related to FreeBSD's use of termcap vs terminfo and some missing capabilities in the termcap file. I can't tell if it's intentional or not. In any case, maybe these tests should just get skipped on FreeBSD. They only affect the Jupyter implementation which is only available if ipython is available.

Longer term, I think Blessed (One of enlighten's dependencies) probably needs to be modified to optionally use an alternative source for terminfo. It uses curses, but we talked about using jinxed like we do on Windows. The main problem is it's less flexible, but for cases like the Jupyter manager, it's actually only using those values for translation, so jinxed would actually be better.

Any thoughts?

avylove commented 2 years ago

I looked at it again and realized FreeBSD was using 256 color syntax for CGA colors rather than the simplified format that xterm uses. This meant the colors were not getting referenced to their names. So I added some logic to always attempt to get a name for colors regardless of how they are specified, only falling back to RGB if it can't. Previously only CGA colors referenced names.

This resolved half of the remaining failures. One was a bug that didn't handle sgr0 when it was a single termcap. And the other two were because blink is not supported in FreeBSD's termcap file, so I moved all the blink tests together and put a guard to skip if blink isn't defined.

It looks like everything is passing now. @yurivict can you confirm main is passing for you?

avylove commented 2 years ago

Fixes are in 1.11.1. Thanks for reporting and please let me you if you have any other issues.

yurivict commented 2 years ago

All tests pass now. Thank you for fixing them!