diff --git a/src/p4p/test/test_gw.py b/src/p4p/test/test_gw.py index f740fc5..bf04f9d 100644 --- a/src/p4p/test/test_gw.py +++ b/src/p4p/test/test_gw.py @@ -225,7 +225,7 @@ def test_monitor(self): Q2 = Queue(maxsize=4) with self._ds_client.monitor('pv:ro', Q1.put, notify_disconnect=True): - + self.assertIsInstance(Q1.get(timeout=self.timeout), Disconnected) self.assertEqual(42, Q1.get(timeout=self.timeout)) @@ -296,7 +296,7 @@ def put(pv, op): _log.debug("Exit setUp") def setUpGW(self, usconfig): - cfile = self._cfile = NamedTemporaryFile('w+') + cfile = self._cfile = NamedTemporaryFile(mode='w+') json.dump({ 'version':2, 'clients':[{ @@ -474,7 +474,7 @@ class TestHighLevelChained(TestHighLevel): def setUpGW(self, usconfig): # First GW, connected to upstream server - cfile = self._cfile = NamedTemporaryFile('w+') + cfile = self._cfile = NamedTemporaryFile(mode='w+') json.dump({ 'version':2, 'clients':[{ @@ -510,7 +510,7 @@ def setUpGW(self, usconfig): gw1config = self._app1.servers[u'server1_0'].conf() # Second GW, connected to first - cfile = self._cfile = NamedTemporaryFile('w+') + cfile = self._cfile = NamedTemporaryFile(mode='w+') json.dump({ 'version':2, 'clients':[{ @@ -635,7 +635,7 @@ def log(self): return self._log.read() def write(self, content): - F = NamedTemporaryFile('w+') + F = NamedTemporaryFile(mode='w+') self._files.append(F) F.write(content) F.flush() diff --git a/src/p4p/test/utils.py b/src/p4p/test/utils.py index 4b8d150..7886ec2 100644 --- a/src/p4p/test/utils.py +++ b/src/p4p/test/utils.py @@ -170,9 +170,14 @@ class RegularNamedTemporaryFile(object): """Like tempfile.NamedTemporaryFile which doesn't use O_TEMPORARY on windows """ def __init__(self, *args, **kws): - fd, self.name = tempfile.mkstemp(**kws) + mkstemp_kws = {k: v for k, v in kws.items() + if k in ['suffix', 'prefix', 'dir']} + fd, self.name = tempfile.mkstemp(**mkstemp_kws) try: - self.file = os.fdopen(fd, *args, **kws) + if 'mode' in kws: + self.file = os.fdopen(fd, kws['mode']) + else: + self.file = os.fdopen(fd) self.read = self.file.read self.write = self.file.write self.flush = self.file.flush