Skip to content

Commit

Permalink
fix pypy integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mpnowacki-reef committed Oct 25, 2023
1 parent 7426f9c commit 24f0cac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
* `--quiet` now will implicitly set `--noProgress` option as well
* pypy integration tests

## [3.11.0] - 2023-10-04

Expand Down
19 changes: 18 additions & 1 deletion test/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,12 @@ def should_succeed(
assert any(p.match(line) for p in self.EXPECTED_STDERR_PATTERNS), \
f'Unexpected stderr line: {repr(line)}'

if platform.python_implementation().lower() == 'pypy':
# TODO: remove after pypy removes the leftover print and resolve
# https://github.com/Backblaze/B2_Command_Line_Tool/issues/936
while stdout.startswith('/'):
stdout = stdout.split('\n', 1)[-1]

if expected_pattern is not None:
assert re.search(expected_pattern, stdout), \
f'did not match pattern="{expected_pattern}", stdout="{stdout}"'
Expand All @@ -454,7 +460,12 @@ def should_succeed_json(self, args, additional_env: Optional[dict] = None):
if there was an error; otherwise, treats the stdout as JSON and returns
the data in it.
"""
return json.loads(self.should_succeed(args, additional_env=additional_env))
result = self.should_succeed(args, additional_env=additional_env)
try:
loaded_result = json.loads(result)
except json.JSONDecodeError:
raise ValueError(f'{result} is not a valid json')
return loaded_result

def should_fail(self, args, expected_pattern, additional_env: Optional[dict] = None):
"""
Expand All @@ -464,6 +475,12 @@ def should_fail(self, args, expected_pattern, additional_env: Optional[dict] = N
status, stdout, stderr = run_command(self.command, args, additional_env)
assert status != 0, 'ERROR: should have failed'

if platform.python_implementation().lower() == 'pypy':
# TODO: remove after pypy removes the leftover print and resolve
# https://github.com/Backblaze/B2_Command_Line_Tool/issues/936
while stdout.startswith('/'):
stdout = stdout.split('\n', 1)[-1]

assert re.search(expected_pattern, stdout + stderr), \
f'did not match pattern="{expected_pattern}", stdout="{stdout}", stderr="{stderr}"'

Expand Down

0 comments on commit 24f0cac

Please sign in to comment.