From 03ba3b7125fb71f27556ed6473fde1c607fd8935 Mon Sep 17 00:00:00 2001 From: Dan g Date: Tue, 31 Jul 2018 14:52:46 -0400 Subject: [PATCH] replace list dereferencing with itertools.chain for py2 --- tests.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/tests.py b/tests.py index b856bcd..fbe5b7b 100644 --- a/tests.py +++ b/tests.py @@ -1,4 +1,5 @@ import base64 +import itertools import logging import os import socket @@ -71,10 +72,9 @@ class TCPStatsdMetricCollectionTests(testing.AsyncHTTPTestCase): path = ('foo', 'bar') value = 500 metric_type = 'c' - expected = "{}:{}|{}\n".format( - '.'.join((self.namespace, 'counters', *path)), - value, - metric_type) + expected = "{}:{}|{}\n".format('.'.join(itertools.chain((self.namespace, 'counters'), path)), + value, + metric_type) self.application.statsd.send(path, value, metric_type) mock_sock.assert_called_once_with(expected.encode()) @@ -84,10 +84,9 @@ class TCPStatsdMetricCollectionTests(testing.AsyncHTTPTestCase): path = ('foo', 'bar') value = 500 metric_type = 'ms' - expected = "{}:{}|{}\n".format( - '.'.join((self.namespace, 'timers', *path)), - value, - metric_type) + expected = "{}:{}|{}\n".format('.'.join(itertools.chain((self.namespace, 'timers'), path)), + value, + metric_type) self.application.statsd.send(path, value, metric_type) mock_sock.assert_called_once_with(expected.encode()) @@ -213,10 +212,9 @@ class UDPStatsdMetricCollectionTests(testing.AsyncHTTPTestCase): path = ('foo', 'bar') value = 500 metric_type = 'c' - expected = "{}:{}|{}".format( - '.'.join((self.namespace, 'counters', *path)), - value, - metric_type) + expected = "{}:{}|{}".format('.'.join(itertools.chain((self.namespace, 'counters'), path)), + value, + metric_type) self.application.statsd.send(path, value, metric_type) mock_sock.assert_called_once_with( @@ -228,10 +226,9 @@ class UDPStatsdMetricCollectionTests(testing.AsyncHTTPTestCase): path = ('foo', 'bar') value = 500 metric_type = 'ms' - expected = "{}:{}|{}".format( - '.'.join((self.namespace, 'timers', *path)), - value, - metric_type) + expected = "{}:{}|{}".format('.'.join(itertools.chain((self.namespace, 'timers'), path)), + value, + metric_type) self.application.statsd.send(path, value, metric_type) mock_sock.assert_called_once_with(