8000 Several small test fixes by andersschuller · Pull Request #50 · prometheus/client_python · GitHub
[go: up one dir, main page]

Skip to content

Several small test fixes #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion prometheus_client/exposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,5 @@ def _use_gateway(method, gateway, job, registry, grouping_key, timeout):
def instance_ip_grouping_key():
'''Grouping key with instance set to the IP Address of this host.'''
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('', 0))
s.connect(('localhost', 0))
return {'instance': s.getsockname()[0]}
4 changes: 3 additions & 1 deletion tests/graphite_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def run(self):
self.t = ServingThread()
self.t.start()

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

def test_nolabels(self):
counter = Counter('c', 'help', registry=self.registry)
Expand Down
7 changes: 4 additions & 3 deletions tests/test_client.py
8588
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,16 @@ def setUp(self):
self.requests = requests = []
class TestHandler(BaseHTTPRequestHandler):
def do_PUT(self):
self.send_response(201)
length = int(self.headers['content-length'])
requests.append((self, self.rfile.read(length)))
self.send_response(201)
self.end_headers()

do_POST = do_PUT
do_DELETE = do_PUT

httpd = HTTPServer(('', 0), TestHandler)
self.address = ':'.join([str(x) for x in httpd.server_address])
self.address = 'localhost:' + str(httpd.server_address[1])
class TestServer(threading.Thread):
def run(self):
httpd.handle_request()
Expand Down Expand Up @@ -466,7 +467,7 @@ def test_delete(self):
self.assertEqual(self.requests[0][0].headers.get('content-type'), CONTENT_TYPE_LATEST)
self.assertEqual(self.requests[0][1], b'')

def test_pushadd_with_groupingkey(self):
def test_delete_with_groupingkey(self):
delete_from_gateway(self.address, "my_job", {'a': 9})
self.assertEqual(self.requests[0][0].command, 'DELETE')
self.assertEqual(self.requests[0][0].path, '/job/my_job/a/9')
Expand Down
0