-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
try: | ||
from configparser import ConfigParser | ||
except ImportError: | ||
from ConfigParser import ConfigParser | ||
|
||
import pytest | ||
|
||
|
||
CLI_OPTION_PREFIX = '--' | ||
|
||
|
||
class CollectConfig(object): | ||
""" | ||
A pytest plugin to gets the configuration file. | ||
""" | ||
def __init__(self): | ||
self.path = None | ||
|
||
def pytest_cmdline_main(self, config): | ||
self.path = str(config.inifile) | ||
|
||
|
||
def merge_config(args): | ||
collect_config = CollectConfig() | ||
pytest.main(['--collect-only'], plugins=[collect_config]) | ||
if not collect_config.path: | ||
return | ||
|
||
config = ConfigParser() | ||
config.read(collect_config.path) | ||
if not config.has_section('pytest-watch'): | ||
return | ||
|
||
for cli_name in args: | ||
if not cli_name.startswith(CLI_OPTION_PREFIX): | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
joeyespo
Author
Owner
|
||
continue | ||
config_name = cli_name[len(CLI_OPTION_PREFIX):] | ||
|
||
# Let CLI options take precedence | ||
if args[cli_name]: | ||
continue | ||
|
||
# Find config option | ||
if not config.has_option('pytest-watch', config_name): | ||
continue | ||
|
||
# Merge config option using the expected type | ||
if isinstance(args[cli_name], bool): | ||
args[cli_name] = config.getboolean('pytest-watch', config_name) | ||
else: | ||
args[cli_name] = config.get('pytest-watch', config_name) |
This file was deleted.
Oops, something went wrong.
This means ini files can not set options like
<directories>
, in any way. Indeed, both<directories>
anddirectories
are ignored from the ini file.I dont think thats really a desirable behavior.