Skip to content

Commit

Permalink
reporters: rename JsonObject to JsonStream
Browse files Browse the repository at this point in the history
To match the current *PickleStream style names.
  • Loading branch information
radhermit committed Aug 26, 2019
1 parent a817d49 commit c8edc53
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/pkgcheck/reporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ def finish(self):
self.out.write('</checks>')


class JsonObject(base.Reporter):
"""Generate a stream of JSON result objects."""
class JsonStream(base.Reporter):
"""Generate a stream of result objects serialized in JSON."""

priority = -1001

Expand Down
2 changes: 1 addition & 1 deletion src/pkgcheck/scripts/pkgcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def _replay(options, out, err):
# assume JSON encoded file, fallback to pickle format
try:
for line in options.results_file:
result = reporters.JsonObject.from_json(line)
result = reporters.JsonStream.from_json(line)
reporter.report(result)
except (JSONDecodeError, UnicodeDecodeError):
options.results_file.seek(0)
Expand Down
12 changes: 6 additions & 6 deletions tests/module/test_pkgcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,16 @@ def test_pkgcheck_scan(self, check, result, capsys, cache_dir):
with open(expected_path) as expected:
assert out == expected.read()

# JsonObject reporter, cache results to compare against repo run
with patch('sys.argv', self.args + ['-R', 'JsonObject'] + args), \
# JsonStream reporter, cache results to compare against repo run
with patch('sys.argv', self.args + ['-R', 'JsonStream'] + args), \
patch('pkgcheck.base.CACHE_DIR', cache_dir):
with pytest.raises(SystemExit) as excinfo:
self.script()
out, err = capsys.readouterr()
assert err == ''
assert excinfo.value.code == 0
for line in out.rstrip('\n').split('\n'):
deserialized_result = reporters.JsonObject.from_json(line)
deserialized_result = reporters.JsonStream.from_json(line)
assert deserialized_result.__class__.__name__ == keyword
self._results[repo].add(deserialized_result)
tested = True
Expand Down Expand Up @@ -376,7 +376,7 @@ def test_pkgcheck_scan_repos(self, capsys, cache_dir, tmp_path):
unknown_results = []
repo_dir = pjoin(self.testdir, 'repos', repo)
args = ['-r', repo_dir, '-c', ','.join(const.CHECKS)]
with patch('sys.argv', self.args + ['-R', 'JsonObject'] + args), \
with patch('sys.argv', self.args + ['-R', 'JsonStream'] + args), \
patch('pkgcheck.base.CACHE_DIR', cache_dir):
with pytest.raises(SystemExit) as excinfo:
self.script()
Expand All @@ -385,7 +385,7 @@ def test_pkgcheck_scan_repos(self, capsys, cache_dir, tmp_path):
assert out, f'{repo} repo failed, no results'
assert excinfo.value.code == 0
for line in out.rstrip('\n').split('\n'):
result = reporters.JsonObject.from_json(line)
result = reporters.JsonStream.from_json(line)
# ignore results generated from stubs
stubs = (getattr(result, x, None) for x in ('category', 'package'))
if any(x == 'stub' for x in stubs):
Expand Down Expand Up @@ -588,7 +588,7 @@ def test_missing_file_arg(self, capsys):
assert excinfo.value.code == 2

def test_replay(self, capsys):
for reporter_cls in (reporters.BinaryPickleStream, reporters.JsonObject):
for reporter_cls in (reporters.BinaryPickleStream, reporters.JsonStream):
with tempfile.NamedTemporaryFile() as f:
out = PlainTextFormatter(f)
reporter = reporter_cls(out=out)
Expand Down
4 changes: 2 additions & 2 deletions tests/module/test_reporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ class TestBinaryPickleStream(TestPickleStream):
reporter_cls = reporters.BinaryPickleStream


class TestJsonObject(BaseReporter):
class TestJsonStream(BaseReporter):

reporter_cls = reporters.JsonObject
reporter_cls = reporters.JsonStream

def test_add_report(self, capsys):
self.reporter = self.mk_reporter()
Expand Down

0 comments on commit c8edc53

Please sign in to comment.