Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): support file configuration overrides -- @tonybaloney (#179)
* initial prototype for file configuration * only load the radon.cfg if it exists * add some basic tests and fix some erroneous behaviours * Put the configuration in a module property so that it is used for the default values. Changing configuration once module is imported will not take effect * Update documentation.
- Loading branch information
1 parent
4fa76b7
commit 92fa247
Showing
4 changed files
with
201 additions
and
18 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
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,25 @@ | ||
import pytest | ||
import textwrap | ||
import os | ||
|
||
|
||
class RadonConfig(object): | ||
def __init__(self): | ||
self._fname = os.path.join(os.path.dirname(__file__), 'radon.cfg') | ||
|
||
def write(self, text): | ||
_cfg = textwrap.dedent(text) | ||
with open(self._fname, 'w') as cfg_f: | ||
cfg_f.write("# Autogenerated from pytest \n[radon]\n") | ||
cfg_f.write(_cfg) | ||
|
||
def __del__(self): | ||
with open(self._fname, 'w') as cfg_f: | ||
cfg_f.write('# Session completed') | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def radon_config(): | ||
r = RadonConfig() | ||
yield r | ||
del r |
Oops, something went wrong.