replace list dereferencing with itertools.chain for py2

This commit is contained in:
Dan g 2018-07-31 14:52:46 -04:00
parent 924735c24e
commit 03ba3b7125

View file

@ -1,4 +1,5 @@
import base64 import base64
import itertools
import logging import logging
import os import os
import socket import socket
@ -71,10 +72,9 @@ class TCPStatsdMetricCollectionTests(testing.AsyncHTTPTestCase):
path = ('foo', 'bar') path = ('foo', 'bar')
value = 500 value = 500
metric_type = 'c' metric_type = 'c'
expected = "{}:{}|{}\n".format( expected = "{}:{}|{}\n".format('.'.join(itertools.chain((self.namespace, 'counters'), path)),
'.'.join((self.namespace, 'counters', *path)), value,
value, metric_type)
metric_type)
self.application.statsd.send(path, value, metric_type) self.application.statsd.send(path, value, metric_type)
mock_sock.assert_called_once_with(expected.encode()) mock_sock.assert_called_once_with(expected.encode())
@ -84,10 +84,9 @@ class TCPStatsdMetricCollectionTests(testing.AsyncHTTPTestCase):
path = ('foo', 'bar') path = ('foo', 'bar')
value = 500 value = 500
metric_type = 'ms' metric_type = 'ms'
expected = "{}:{}|{}\n".format( expected = "{}:{}|{}\n".format('.'.join(itertools.chain((self.namespace, 'timers'), path)),
'.'.join((self.namespace, 'timers', *path)), value,
value, metric_type)
metric_type)
self.application.statsd.send(path, value, metric_type) self.application.statsd.send(path, value, metric_type)
mock_sock.assert_called_once_with(expected.encode()) mock_sock.assert_called_once_with(expected.encode())
@ -213,10 +212,9 @@ class UDPStatsdMetricCollectionTests(testing.AsyncHTTPTestCase):
path = ('foo', 'bar') path = ('foo', 'bar')
value = 500 value = 500
metric_type = 'c' metric_type = 'c'
expected = "{}:{}|{}".format( expected = "{}:{}|{}".format('.'.join(itertools.chain((self.namespace, 'counters'), path)),
'.'.join((self.namespace, 'counters', *path)), value,
value, metric_type)
metric_type)
self.application.statsd.send(path, value, metric_type) self.application.statsd.send(path, value, metric_type)
mock_sock.assert_called_once_with( mock_sock.assert_called_once_with(
@ -228,10 +226,9 @@ class UDPStatsdMetricCollectionTests(testing.AsyncHTTPTestCase):
path = ('foo', 'bar') path = ('foo', 'bar')
value = 500 value = 500
metric_type = 'ms' metric_type = 'ms'
expected = "{}:{}|{}".format( expected = "{}:{}|{}".format('.'.join(itertools.chain((self.namespace, 'timers'), path)),
'.'.join((self.namespace, 'timers', *path)), value,
value, metric_type)
metric_type)
self.application.statsd.send(path, value, metric_type) self.application.statsd.send(path, value, metric_type)
mock_sock.assert_called_once_with( mock_sock.assert_called_once_with(