diff --git a/rtv/terminal.py b/rtv/terminal.py index 40555a4..4273958 100644 --- a/rtv/terminal.py +++ b/rtv/terminal.py @@ -52,8 +52,11 @@ class Terminal(object): self.loader = LoadScreen(self) self._display = None - # TODO: Load from custom location - self._mailcap_dict = mailcap.getcaps() + try: + self._mailcap_dict = mailcap.getcaps() + except IOError: + # Python 2 raises an error, python 3 does not + self._mailcap_dict = {} @property def up_arrow(self): diff --git a/tests/test_objects.py b/tests/test_objects.py index f745b3e..707562a 100644 --- a/tests/test_objects.py +++ b/tests/test_objects.py @@ -56,7 +56,7 @@ def test_objects_load_screen_exception_handled(terminal, stdscr, use_ascii): assert not terminal.loader._is_running assert not terminal.loader._animator.is_alive() assert isinstance(terminal.loader.exception, requests.ConnectionError) - error_message = 'ConnectionError'.encode('ascii' if ascii else 'utf-8') + error_message = 'ConnectionError'.encode('ascii' if use_ascii else 'utf-8') stdscr.subwin.addstr.assert_called_with(1, 1, error_message) @@ -155,7 +155,7 @@ def test_objects_load_screen_nested_complex(terminal, stdscr, use_ascii): assert terminal.loader.depth == 0 assert not terminal.loader._is_running assert not terminal.loader._animator.is_alive() - error_message = 'ConnectionError'.encode('ascii' if ascii else 'utf-8') + error_message = 'ConnectionError'.encode('ascii' if use_ascii else 'utf-8') stdscr.subwin.addstr.assert_called_once_with(1, 1, error_message) diff --git a/tests/test_terminal.py b/tests/test_terminal.py index 07584af..c53c577 100644 --- a/tests/test_terminal.py +++ b/tests/test_terminal.py @@ -154,7 +154,7 @@ def test_terminal_clean_unescape_html(terminal, use_ascii): terminal.config['ascii'] = use_ascii text = terminal.clean('<') assert isinstance(text, six.binary_type) - assert text.decode('ascii' if ascii else 'utf-8') == '<' + assert text.decode('ascii' if use_ascii else 'utf-8') == '<' @pytest.mark.parametrize('use_ascii', [True, False])