BartSte / khalorg

An interface between org mode and khal cli calendar
https://pypi.org/project/khalorg/
MIT License
23 stars 0 forks source link

Test are dependend on a khal config file #2

Closed BartSte closed 10 months ago

BartSte commented 10 months ago

Problem

Got the following error when running in a workflow:

______________________ TestCalendar.test_datetime_format _______________________
237 tests/test_khal/helpers.py:12: in setUp
238     self.calendar = Calendar('test_calendar')
239 src/khalorg/khal/calendar.py:95: in __init__
240     self.config: dict = get_config(path_config)
241 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
242 
243 config_path = None
244 _get_color_from_vdir = <function get_color_from_vdir at 0x7f23a14f0d30>
245 _get_vdir_type = <function get_vdir_type at 0x7f23a14f0ee0>
246 
247     def get_config(
248             config_path: Optional[str]=None,
249             _get_color_from_vdir: Callable=get_color_from_vdir,
250             _get_vdir_type: Callable=get_vdir_type) -> ConfigObj:
251         """reads the config file, validates it and return a config dict
252     
253         :param config_path: path to a custom config file, if none is given the
254                             default locations will be searched
255         :param _get_color_from_vdir: override get_color_from_vdir for testing purposes
256         :param _get_vdir_type: override get_vdir_type for testing purposes
257         :returns: configuration
258         """
259         if config_path is None:
260             config_path = find_configuration_file()
261         if config_path is None or not os.path.exists(config_path):
262 >           raise NoConfigFile()
263 E           khal.settings.exceptions.NoConfigFile
264 
265 .venv/lib/python3.10/site-packages/khal/settings/settings.py:102: NoConfigFile

Solution

Create a khal config that is used for the test only.