Skip to content

Commit

Permalink
fix: subprocess output is byte not str
Browse files Browse the repository at this point in the history
  • Loading branch information
posterzh committed Jun 22, 2022
1 parent 4c42322 commit 2f654d7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hm_pyhelper/miner_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_gateway_mfr_version() -> Version:

# Parse gateway_mfr version
try:
version_str = run_gateway_mfr_result.stdout.rpartition(' ')[-1]
version_str = run_gateway_mfr_result.stdout.decode().rpartition(' ')[-1]
gateway_mfr_version = Version(version_str)

return gateway_mfr_version
Expand Down
4 changes: 2 additions & 2 deletions hm_pyhelper/tests/test_miner_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_get_gateway_mfr_version_invalid_version(self, mocked_subprocess_run):
mocked_subprocess_run.assert_called_once_with(
[ANY, '--version'], capture_output=True, check=True)

@patch('subprocess.run', return_value=SubprocessResult(stdout='gateway_mfr 0.1.7'))
@patch('subprocess.run', return_value=SubprocessResult(stdout=b'gateway_mfr 0.1.7'))
def test_get_gateway_mfr_version_v017(self, mocked_subprocess_run):
version = get_gateway_mfr_version()

Expand All @@ -129,7 +129,7 @@ def test_get_gateway_mfr_version_v017(self, mocked_subprocess_run):
mocked_subprocess_run.assert_called_once_with(
[ANY, '--version'], capture_output=True, check=True)

@patch('subprocess.run', return_value=SubprocessResult(stdout='gateway_mfr 0.2.1'))
@patch('subprocess.run', return_value=SubprocessResult(stdout=b'gateway_mfr 0.2.1'))
def test_get_gateway_mfr_version_v021(self, mocked_subprocess_run):
version = get_gateway_mfr_version()

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='hm_pyhelper',
version='0.13.28',
version='0.13.29',
author="Nebra Ltd",
author_email="[email protected]",
description="Helium Python Helper",
Expand Down

0 comments on commit 2f654d7

Please sign in to comment.