10000 Merge pull request #50 from andersschuller/test-fixes · Syncano/client_python@91a928b · GitHub
[go: up one dir, main page]

Skip to content

Commit 91a928b

Browse files
committed
Merge pull request prometheus#50 from andersschuller/test-fixes
Several small test fixes
2 parents 0b7e85f + 7cf945c commit 91a928b

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

prometheus_client/exposition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,5 @@ def _use_gateway(method, gateway, job, registry, grouping_key, timeout):
126126
def instance_ip_grouping_key():
127127
'''Grouping key with instance set to the IP Address of this host.'''
128128
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
129-
s.connect(('', 0))
129+
s.connect(('localhost', 0))
130130
return {'instance': s.getsockname()[0]}

tests/graphite_bridge.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ def run(self):
2828
self.t = ServingThread()
2929
self.t.start()
3030

31-
self.gb = GraphiteBridge(server.server_address, self.registry, _time=FakeTime())
31+
# Explicitly use localhost as the target host, since connecting to 0.0.0.0 fails on Windows
32+
address = ('localhost', server.server_address[1])
33+
self.gb = GraphiteBridge(address, self.registry, _time=FakeTime())
3234

3335
def test_nolabels(self):
3436
counter = Counter('c', 'help', registry=self.registry)

tests/test_client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,16 @@ def setUp(self):
408408
self.requests = requests = []
409409
class TestHandler(BaseHTTPRequestHandler):
410410
def do_PUT(self):
411-
self.send_response(201)
412411
length = int(self.headers['content-length'])
413412
requests.append((self, self.rfile.read(length)))
413+
self.send_response(201)
414+
self.end_headers()
414415

415416
do_POST = do_PUT
416417
do_DELETE = do_PUT
417418

418419
httpd = HTTPServer(('', 0), TestHandler)
419-
self.address = ':'.join([str(x) for x in httpd.server_address])
420+
self.address = 'localhost:' + str(httpd.server_address[1])
420421
class TestServer(threading.Thread):
421422
def run(self):
422423
httpd.handle_request()
@@ -466,7 +467,7 @@ def test_delete(self):
466467
self.assertEqual(self.requests[0][0].headers.get('content-type'), CONTENT_TYPE_LATEST)
467468
self.assertEqual(self.requests[0][1], b'')
468469

469-
def test_pushadd_with_groupingkey(self):
470+
def test_delete_with_groupingkey(self):
470471
delete_from_gateway(self.address, "my_job", {'a': 9})
471472
self.assertEqual(self.requests[0][0].command, 'DELETE')
472473
self.assertEqual(self.requests[0][0].path, '/job/my_job/a/9')

0 commit comments

Comments
 (0)
0