| 1 | diff --git a/tests/test_terminal.py b/tests/test_terminal.py
|
| 2 | index bc98698..c178d0e 100644
|
| 3 | |
| 4 | |
| 5 | @@ -174,12 +174,12 @@ def test_terminal_add_line(terminal, stdscr, use_ascii):
|
| 6 | terminal.config['ascii'] = use_ascii
|
| 7 |
|
| 8 | terminal.add_line(stdscr, 'hello')
|
| 9 | - assert stdscr.addstr.called_with(0, 0, 'hello'.encode('ascii'))
|
| 10 | + stdscr.addstr.assert_called_with(0, 0, 'hello'.encode('ascii'))
|
| 11 | stdscr.reset_mock()
|
| 12 |
|
| 13 | # Text will be drawn, but cut off to fit on the screen
|
| 14 | terminal.add_line(stdscr, 'hello', row=3, col=75)
|
| 15 | - assert stdscr.addstr.called_with((3, 75, 'hell'.encode('ascii')))
|
| 16 | + stdscr.addstr.assert_called_with(3, 75, 'hell'.encode('ascii'))
|
| 17 | stdscr.reset_mock()
|
| 18 |
|
| 19 | # Outside of screen bounds, don't even try to draw the text
|
| 20 | @@ -536,12 +536,6 @@ def test_terminal_open_pager(terminal, stdscr):
|
| 21 | assert Popen.called
|
| 22 | assert not stdscr.addstr.called
|
| 23 |
|
| 24 | - # Raise an OS error
|
| 25 | - Popen.side_effect = side_effect
|
| 26 | - terminal.open_pager(data)
|
| 27 | - message = 'Could not open pager fake'.encode('ascii')
|
| 28 | - assert stdscr.addstr.called_with(0, 0, message)
|
| 29 | -
|
| 30 |
|
| 31 | def test_terminal_open_urlview(terminal, stdscr):
|
| 32 |
|
| 33 | @@ -563,12 +557,6 @@ def test_terminal_open_urlview(terminal, stdscr):
|
| 34 | terminal.open_urlview(data)
|
| 35 | assert stdscr.subwin.addstr.called
|
| 36 |
|
| 37 | - # Raise an OS error
|
| 38 | - Popen.side_effect = side_effect
|
| 39 | - terminal.open_urlview(data)
|
| 40 | - message = 'Failed to open fake'.encode('utf-8')
|
| 41 | - assert stdscr.addstr.called_with(0, 0, message)
|
| 42 | -
|
| 43 |
|
| 44 | def test_terminal_strip_textpad(terminal):
|
| 45 |
|
| 46 | diff --git a/tuir/config.py b/tuir/config.py
|
| 47 | index 7a8a4d5..bfc1bac 100644
|
| 48 | |
| 49 | |
| 50 | @@ -130,9 +130,7 @@ class Config(object):
|
| 51 |
|
| 52 | config = configparser.RawConfigParser()
|
| 53 | if os.path.exists(filename):
|
| 54 | - with codecs.open(filename, encoding='utf-8') as fp:
|
| 55 | - config.readfp(fp)
|
| 56 | -
|
| 57 | + config.read(filename, encoding='utf-8')
|
| 58 | return cls._parse_tuir_file(config)
|
| 59 |
|
| 60 | @staticmethod
|
| 61 | @@ -141,12 +139,13 @@ class Config(object):
|
| 62 | section = ''
|
| 63 |
|
| 64 | if config.has_section('tuir'):
|
| 65 | - tuir = dict(config.items('tuir'))
|
| 66 | section = 'tuir'
|
| 67 | elif config.has_section('rtv'):
|
| 68 | - # Backwards compatibility for rtv configs, bug #13
|
| 69 | - tuir = dict(config.items('rtv'))
|
| 70 | section = 'rtv'
|
| 71 | +
|
| 72 | + # Get all items from the section if it exists
|
| 73 | + if section:
|
| 74 | + tuir = dict(config[section].items())
|
| 75 |
|
| 76 | # convert non-string params to their typed representation
|
| 77 | params = {
|
| 78 | diff --git a/tuir/packages/praw/decorators.py b/tuir/packages/praw/decorators.py
|
| 79 | index 77bffab..9680b95 100644
|
| 80 | |
| 81 | |
| 82 | @@ -38,7 +38,7 @@ from warnings import filterwarnings, warn
|
| 83 |
|
| 84 | # Enable deprecation warnings from this module
|
| 85 | filterwarnings('default', category=DeprecationWarning,
|
| 86 | - module='^praw\.decorators$')
|
| 87 | + module=r'^praw\.decorators$')
|
| 88 |
|
| 89 |
|
| 90 | def alias_function(function, class_name):
|
| 91 | diff --git a/tuir/packages/praw/settings.py b/tuir/packages/praw/settings.py
|
| 92 | index 49821fb..57930e0 100644
|
| 93 | |
| 94 | |
| 95 | @@ -37,9 +37,10 @@ def _load_configuration():
|
| 96 | locations = [os.path.join(module_dir, 'praw.ini'), 'praw.ini']
|
| 97 | if os_config_path is not None:
|
| 98 | locations.insert(1, os.path.join(os_config_path, 'praw.ini'))
|
| 99 | - if not config.read(locations):
|
| 100 | - raise Exception('Could not find config file in any of: {0}'
|
| 101 | - .format(locations))
|
| 102 | - return config
|
| 103 | + for filename in locations:
|
| 104 | + if config.read(filename, encoding='utf-8'):
|
| 105 | + return config
|
| 106 | +
|
| 107 | + raise Exception('Could not find config file in any of: {0}'.format(locations))
|
| 108 | CONFIG = _load_configuration()
|
| 109 | del _load_configuration
|
| 110 | diff --git a/tuir/theme.py b/tuir/theme.py
|
| 111 | index 57b3288..75933df 100644
|
| 112 | |
| 113 | |
| 114 | @@ -395,13 +395,14 @@ class Theme(object):
|
| 115 | """
|
| 116 | _logger.info('Loading theme %s', filename)
|
| 117 |
|
| 118 | + config = configparser.ConfigParser()
|
| 119 | + config.optionxform = six.text_type # Preserve case
|
| 120 | try:
|
| 121 | - config = configparser.ConfigParser()
|
| 122 | - config.optionxform = six.text_type # Preserve case
|
| 123 | - with codecs.open(filename, encoding='utf-8') as fp:
|
| 124 | + if not config.read(filename, encoding='utf-8'):
|
| 125 | + raise ConfigError('Could not read theme file: {}'.format(filename))
|
| 126 | config.readfp(fp)
|
| 127 | except configparser.ParsingError as e:
|
| 128 | - raise ConfigError(e.message)
|
| 129 | + raise ConfigError(str(e))
|
| 130 |
|
| 131 | if not config.has_section('theme'):
|
| 132 | raise ConfigError(
|