old_contents: from collections import deque
  import datetime
  
  from tornado import gen
  
  from distributed.diagnostics.worker_monitor import (resource_profile_plot,
          resource_profile_update, resource_append)
  from distributed.diagnostics.scheduler import workers, tasks
  from distributed.utils_test import gen_cluster
  
  @gen_cluster()
  def test_resource_monitor_plot(s, a, b):
      while any('last-seen' not in v for v in s.host_info.values()):
          yield gen.sleep(0.01)
  
      times_buffer = [1000, 1001, 1003]
      workers_buffer = [{},
                        {'10.10.20.86': {'cpu': 15.9, 'memory-percent': 63.0}},
                        {'10.10.20.86': {'cpu': 14.9, 'memory-percent': 64.0},
                         '10.10.20.87': {'cpu': 13.9, 'memory-percent': 64.0}}]
  
      source, plot = resource_profile_plot()
      resource_profile_update(source, workers_buffer, times_buffer)
  
      assert source.data['workers'] == ['10.10.20.86', '10.10.20.87']
      assert len(source.data['cpu']) == 2
      assert source.data['cpu'][0] == ['null', 15.9, 14.9]
      assert source.data['cpu'][1] == ['null', 'null', 13.9]
  
      assert source.data['times'][0] == ['null', 1001000, 1003000]
      assert source.data['times'][1] == ['null','null', 1003000]
      assert len(source.data['times']) == 2
      assert len(source.data['memory-percent']) == 2
  
  
  def test_resource_append():
      lists = {'time': [], 'cpu': [], 'memory-percent': []}
      msg = {'10.10.20.86': {'cpu': 10, 'memory-percent': 50, 'time': 2000},
             '10.10.20.87': {'cpu': 30, 'memory-percent': 70, 'time': 1000}}
  
      resource_append(lists, msg)
      assert lists == {'time': [1500000], 'cpu': [20], 'memory-percent': [60]}
  
new_contents: from collections import deque
  import datetime
  
  from tornado import gen
  
  from distributed.diagnostics.worker_monitor import (resource_profile_plot,
          resource_profile_update, resource_append)
  from distributed.diagnostics.scheduler import workers, tasks
  from distributed.utils_test import gen_cluster
  
  @gen_cluster()
  def test_resource_monitor_plot(s, a, b):
      while any('last-seen' not in v for v in s.host_info.values()):
          yield gen.sleep(0.01)
  
      times_buffer = [1000, 1001, 1003]
      workers_buffer = [{},
                        {'10.10.20.86': {'cpu': 15.9, 'memory-percent': 63.0}},
                        {'10.10.20.86': {'cpu': 14.9, 'memory-percent': 64.0},
                         '10.10.20.87': {'cpu': 13.9, 'memory-percent': 64.0}}]
  
      source, plot = resource_profile_plot()
      resource_profile_update(source, workers_buffer, times_buffer)
  
      assert source.data['workers'] == ['10.10.20.86', '10.10.20.87']
      assert len(source.data['cpu']) == 2
      assert source.data['cpu'][0] == ['null', 15.9, 14.9]
      assert source.data['cpu'][1] == ['null', 'null', 13.9]
  
      assert source.data['times'][0] == ['null', 1001000, 1003000]
      assert source.data['times'][1] == ['null','null', 1003000]
      assert len(source.data['times']) == 2
      assert len(source.data['memory-percent']) == 2
  
  
  def test_resource_append():
      lists = {'time': [], 'cpu': [], 'memory-percent': []}
      msg = {'10.10.20.86': {'cpu': 10, 'memory-percent': 50, 'time': 2000},
             '10.10.20.87': {'cpu': 30, 'memory-percent': 70, 'time': 1000}}
  
      resource_append(lists, msg)
      assert lists == {'time': [1500000], 'cpu': [0.2], 'memory-percent': [0.6]}
  
subject: Fix test