Commit 0b800712 authored by Jason Madden's avatar Jason Madden

Fix test__makefile_ref under Windows 10 with new psutil 4.4 which actually...

Fix test__makefile_ref under Windows 10 with new psutil 4.4 which actually started returning open files, not just connections.
parent c22e4de9
...@@ -712,6 +712,11 @@ else: ...@@ -712,6 +712,11 @@ else:
# as -1 there, so we can't fully check those. # as -1 there, so we can't fully check those.
def get_open_files(): def get_open_files():
"""
Return a list of popenfile and pconn objects.
Note that other than `fd`, they have different attributes.
"""
results = dict() results = dict()
process = psutil.Process() process = psutil.Process()
results['data'] = process.open_files() + process.connections('all') results['data'] = process.open_files() + process.connections('all')
......
from __future__ import print_function
import os import os
from gevent import monkey; monkey.patch_all() from gevent import monkey; monkey.patch_all()
import re import re
...@@ -64,7 +65,7 @@ class Test(unittest.TestCase): ...@@ -64,7 +65,7 @@ class Test(unittest.TestCase):
open_files = get_open_files() open_files = get_open_files()
sockname = sock.getsockname() sockname = sock.getsockname()
for x in open_files['data']: for x in open_files['data']:
if x.laddr == sockname: if getattr(x, 'laddr', None) == sockname:
assert x.status in (psutil.CONN_LISTEN, psutil.CONN_ESTABLISHED) + self.extra_allowed_open_states, x.status assert x.status in (psutil.CONN_LISTEN, psutil.CONN_ESTABLISHED) + self.extra_allowed_open_states, x.status
return return
raise AssertionError("%r is not open:\n%s" % (sock, open_files['data'])) raise AssertionError("%r is not open:\n%s" % (sock, open_files['data']))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment