Skip to content

Commit

Permalink
Remove trailing whitespace from golden files
Browse files Browse the repository at this point in the history
When system tests are run with the `GENERATE` environment variable set, we regenerate golden files used by these tests. To do this we use the Python `json.dump` function, which adds trailing whitespaces when it is called with the `indent` argument (which we do). From the Python docs at https://docs.python.org/2/library/json.html:

> Note Since the default item separator is ', ', the output might include trailing whitespace when indent is specified. You can use separators=(',', ': ') to avoid this.

Per the suggestion in the docs, this change adds the `separators` argument as well, to avoid generating trailing whitespace.
  • Loading branch information
ycombinator committed Dec 28, 2018
1 parent 2c6030d commit 984a45c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion filebeat/tests/system/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def _test_expected_events(self, test_file, objects):
objects[k] = self.flatten_object(obj, {}, "")
clean_keys(objects[k])

json.dump(objects, f, indent=4, sort_keys=True)
json.dump(objects, f, indent=4, separators=(',', ': '), sort_keys=True)

with open(test_file + "-expected.json", "r") as f:
expected = json.load(f)
Expand Down

0 comments on commit 984a45c

Please sign in to comment.