Load default config from package directory
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
import configparser
|
import configparser
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import importlib.resources
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@@ -140,6 +141,7 @@ class RedditDownloader:
|
|||||||
Path('./default_config.cfg'),
|
Path('./default_config.cfg'),
|
||||||
Path(self.config_directory, 'config.cfg'),
|
Path(self.config_directory, 'config.cfg'),
|
||||||
Path(self.config_directory, 'default_config.cfg'),
|
Path(self.config_directory, 'default_config.cfg'),
|
||||||
|
list(importlib.resources.path('bulkredditdownloader', 'default_config.cfg').gen)[0],
|
||||||
]
|
]
|
||||||
self.config_location = None
|
self.config_location = None
|
||||||
for path in possible_paths:
|
for path in possible_paths:
|
||||||
|
|||||||
@@ -230,3 +230,10 @@ def test_cli_download_hard_fail(test_args: list[str], tmp_path: Path):
|
|||||||
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
test_args = ['download', str(tmp_path), '-v', '--config', 'test_config.cfg'] + test_args
|
||||||
result = runner.invoke(cli, test_args)
|
result = runner.invoke(cli, test_args)
|
||||||
assert result.exit_code != 0
|
assert result.exit_code != 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_cli_download_use_default_config(tmp_path: Path):
|
||||||
|
runner = CliRunner()
|
||||||
|
test_args = ['download', '-vv', str(tmp_path)]
|
||||||
|
result = runner.invoke(cli, test_args)
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|||||||
Reference in New Issue
Block a user