Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update get_battery_level_and_temperature() #4300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Onkar1300
Copy link
Contributor

Update regex to fetch a valid battery 'level' instead of 'Capacity level' to prevent timeout in wait_until_good_state() of battery.py

Update regex to fetch a valid battery 'level' instead of
'Capacity level' to prevent timeout in wait_until_good_state()
of battery.py
@vitorguidi
Copy link
Collaborator

/gcbrun

@@ -40,7 +40,7 @@ def get_battery_level_and_temperature():
output = adb.run_shell_command(['dumpsys', 'battery'])

# Get battery level.
m_battery_level = re.match(r'.*level: (\d+).*', output, re.DOTALL)
m_battery_level = re.match(r'.*\n[\t ]*level: (\d+).*', output, re.DOTALL)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you write a simple unit test for this, so it becomes more explicit what kind of input we are expecting here? As someone who is not dealing with android on an everyday basis, it is hard to understand:

  • Why the previous code broke
  • Why this change solves the above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants