saltstack/salt — pull request #19047 by eliasp (2014-12-17 11:12:44+00:00)
Title: [DO NOT MERGE YET!] 2014.7 modules.file.replace test coverage

Based on the things reported in #18612, attempted to fix in #18615 and an additional case reported in #18841 I started to write some integration tests for `modules.file.replace()`.
All new tests except of `test_replace_issue_18841` work fine after applying the changes to `modules/file.py` also provided by this PR. I need some help with this specific one.
This test sets `search_only=True`:
```Python
ret = self.run_state('file.replace',
name=path_test, pattern='^hello world$', repl='goodbye world', search_only=True)
```
This should result in no `*.bak` file being created.
Running the test shows, that there is a `*.bak` file created instead.
Running the command directly on CLI works just fine.
Inspecting `ret` shows, that the following warning is raised:
```
'search_only' is an invalid keyword argument for 'file.replace'.
If you were trying to pass additional data to be used in a template context, please populate 'context' with 'key: value' pairs.
Your approach will work until Salt Lithium is out. Please update your state files."
```
Can anyone see why `search_only=True` isn't properly detected as keyword here?

Besides the tests which are provided with this PR, some more things should be tested regarding `replace()` such as:
* are the `flags` honored in all cases?
* can matching groups be used in `repl` in different scenarios?
* is `count` respected in different scenarios?
* handling of `bufsize`/`bufsize='file'`? Do multiline operations work properly?

Due to time limits someone else will have to take care of those things.