Overhaul command_line tests (#46682)

This commit is contained in:
Dermot Duffy 2021-03-01 08:27:04 -08:00 committed by GitHub
parent 3ebd5aff98
commit be8584c0bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 699 additions and 535 deletions

View file

@ -145,19 +145,14 @@ class CommandSensorData:
def update(self):
"""Get the latest data with a shell command."""
command = self.command
cache = {}
if command in cache:
prog, args, args_compiled = cache[command]
elif " " not in command:
if " " not in command:
prog = command
args = None
args_compiled = None
cache[command] = (prog, args, args_compiled)
else:
prog, args = command.split(" ", 1)
args_compiled = template.Template(args, self.hass)
cache[command] = (prog, args, args_compiled)
if args_compiled:
try: