Skip to content

Commit

Permalink
give each of the LocalWorkers in the tests a distinct working dir
Browse files Browse the repository at this point in the history
This makes them create their own test.log instead of overwriting the real one.
  • Loading branch information
exarkun committed Mar 28, 2022
1 parent 99a9c0c commit 6e9ec3b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/twisted/trial/_dist/test/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@ def test_childDataReceived(self):
L{AMP} protocol if the right file descriptor, otherwise forwards to
C{ProcessProtocol.childDataReceived}.
"""
localWorker = self.tidyLocalWorker(SpyDataLocalWorkerAMP(), ".", "test.log")
localWorker = self.tidyLocalWorker(
SpyDataLocalWorkerAMP(), self.mktemp(), "test.log"
)
localWorker._outLog = BytesIO()
localWorker.childDataReceived(4, b"foo")
localWorker.childDataReceived(1, b"bar")
Expand Down Expand Up @@ -372,7 +374,9 @@ def test_outReceived(self):
L{LocalWorker.outReceived} logs the output into its C{_outLog} log
file.
"""
localWorker = self.tidyLocalWorker(SpyDataLocalWorkerAMP(), ".", "test.log")
localWorker = self.tidyLocalWorker(
SpyDataLocalWorkerAMP(), self.mktemp(), "test.log"
)
localWorker._outLog = BytesIO()
data = b"The quick brown fox jumps over the lazy dog"
localWorker.outReceived(data)
Expand All @@ -383,7 +387,9 @@ def test_errReceived(self):
L{LocalWorker.errReceived} logs the errors into its C{_errLog} log
file.
"""
localWorker = self.tidyLocalWorker(SpyDataLocalWorkerAMP(), ".", "test.log")
localWorker = self.tidyLocalWorker(
SpyDataLocalWorkerAMP(), self.mktemp(), "test.log"
)
localWorker._errLog = BytesIO()
data = b"The quick brown fox jumps over the lazy dog"
localWorker.errReceived(data)
Expand Down Expand Up @@ -427,7 +433,9 @@ def test_connectionLost(self):
L{LocalWorker.connectionLost} closes the log streams.
"""

localWorker = self.tidyLocalWorker(SpyDataLocalWorkerAMP(), ".", "test.log")
localWorker = self.tidyLocalWorker(
SpyDataLocalWorkerAMP(), self.mktemp(), "test.log"
)
localWorker.connectionLost(None)
self.assertTrue(localWorker._outLog.closed)
self.assertTrue(localWorker._errLog.closed)
Expand All @@ -438,10 +446,9 @@ def test_processEnded(self):
L{LocalWorker.processEnded} calls C{connectionLost} on itself and on
the L{AMP} protocol.
"""

transport = FakeTransport()
protocol = SpyDataLocalWorkerAMP()
localWorker = LocalWorker(protocol, ".", "test.log")
localWorker = LocalWorker(protocol, self.mktemp(), "test.log")
localWorker.makeConnection(transport)
localWorker.processEnded(Failure(CONNECTION_DONE))
self.assertTrue(localWorker._outLog.closed)
Expand Down Expand Up @@ -478,6 +485,6 @@ def failCallRemote(command, directory):

protocol = SpyDataLocalWorkerAMP()
protocol.callRemote = failCallRemote
self.tidyLocalWorker(protocol, ".", "test.log")
self.tidyLocalWorker(protocol, self.mktemp(), "test.log")

self.assertEqual([], self.flushLoggedErrors(RuntimeError))

0 comments on commit 6e9ec3b

Please sign in to comment.