qutebrowser/tests
Florian Bruhin 0e3f6e6b87 Fix initializing of configtypes.QtFont when default_size is None
When initially reading a config.py and trying to validate QtFont values,
Font.default_size is still set to None. This is because it needs to be
initialized later in _late_init, as doing so requires a QApplication.

This results in the following error while running config.py:

  Traceback (most recent call last):
    File "/usr/lib/python3.8/site-packages/qutebrowser/config/configfiles.py", line 731, in read_config_py
      exec(code, module.__dict__)
    File ".../.config/qutebrowser/config.py", line 52, in <module>
      c.fonts.debug_console = 'default_size default_family'
    File "/usr/lib/python3.8/site-packages/qutebrowser/config/config.py", line 611, in __setattr__
      self._config.set_obj(name, value, pattern=self._pattern)
    File "/usr/lib/python3.8/site-packages/qutebrowser/config/config.py", line 457, in set_obj
      self._set_value(opt, value, pattern=pattern,
    File "/usr/lib/python3.8/site-packages/qutebrowser/config/config.py", line 317, in _set_value
      opt.typ.to_py(value)  # for validation
    File "/usr/lib/python3.8/site-packages/qutebrowser/config/configtypes.py", line 1336, in to_py
      if size.lower().endswith('pt'):
  AttributeError: 'NoneType' object has no attribute 'lower'

Similarly to what's done for configtypes.Font, assume that a None size is fine.
Note that the default_size setting already gets validated via a separate regex
anyways.

Our tests didn't catch this because the init_patch patching already set
default_size to a non-None value. While this makes sense for the rest of the
tests, in test_configinit we really should have the real default value.

Fixes #5223

(cherry picked from commit d68f484b6d003e5708fe390a921175c6c7777641)
2020-02-13 12:06:35 +01:00
..
end2end quteprocess: Add Qt 5.14 debug message 2020-01-11 15:36:13 +01:00
helpers Add fonts.default_family setting 2020-01-20 19:50:18 +01:00
manual Fix stale tabs.background_tabs references 2019-04-18 08:21:17 +02:00
unit Fix initializing of configtypes.QtFont when default_size is None 2020-02-13 12:06:35 +01:00
conftest.py Adjust copyrights for 2020 2020-01-04 18:21:17 +01:00
test_conftest.py Adjust copyrights for 2020 2020-01-04 18:21:17 +01:00