Skip to content

Commit

Permalink
Merge pull request #95 from mgorny/py312
Browse files Browse the repository at this point in the history
Replace deprecated assertEquals() with assertEqual() in tests
  • Loading branch information
glyph authored Nov 6, 2023
2 parents 17d72be + eecdeb5 commit b74680b
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 48 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,24 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3.11"]
python: ["3.8", "3.11", "3.12"]
include:
- TOX_ENV: "lint"
python: "3.11"
- TOX_ENV: "py38"
python: "3.8"
- TOX_ENV: "py312"
python: "3.12"
- TOX_ENV: "py311"
python: "3.11"
- TOX_ENV: docs
python: "3.11"
- TOX_ENV: apidocs
python: "3.11"
- TOX_ENV: docs-spellcheck
python: "3.11"
- TOX_ENV: docs-linkcheck
python: "3.11"
allow_failures:
- TOX_ENV: "docs-linkcheck"

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py38, py310, py311, pypy, docs, lint, apidocs, docs-spellcheck
envlist = py38, py310, py311, py312, pypy, docs, lint, apidocs, docs-spellcheck

[testenv]
passenv = *
Expand Down
8 changes: 4 additions & 4 deletions tubes/test/test_fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def test_fanOut(self):
fountB.flowTo(fdB)
ff.drain.receive("foo")

self.assertEquals(fdA.received, ["foo"])
self.assertEquals(fdB.received, ["foo"])
self.assertEqual(fdA.received, ["foo"])
self.assertEqual(fdB.received, ["foo"])


def test_fanReceivesBeforeFountsHaveDrains(self):
Expand All @@ -106,7 +106,7 @@ def test_fanReceivesBeforeFountsHaveDrains(self):
ff.drain.receive("foo")

fount.flowTo(fd)
self.assertEquals(fd.received, [])
self.assertEqual(fd.received, [])


def test_pausingOneOutFountPausesUpstreamFount(self):
Expand All @@ -121,7 +121,7 @@ def test_pausingOneOutFountPausesUpstreamFount(self):
ff.flowTo(out.drain)

fount.pauseFlow()
self.assertEquals(ff.flowIsPaused, 1)
self.assertEqual(ff.flowIsPaused, 1)


def test_oneFountPausesInReceive(self):
Expand Down
20 changes: 10 additions & 10 deletions tubes/test/test_framing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_stringToNetstring(self):
fd = FakeDrain()
ff.flowTo(series(bytesToNetstrings())).flowTo(fd)
ff.drain.receive(b"hello")
self.assertEquals(
self.assertEqual(
fd.received, [b"%(len)d:%(data)s," %
{b"len": len(b"hello"), b"data": b"hello"}]
)
Expand All @@ -42,7 +42,7 @@ def test_bytesToNetstrings(self):
ff.flowTo(series(bytesToNetstrings())).flowTo(fd)
ff.drain.receive(b"hello")
ff.drain.receive(b"world")
self.assertEquals(
self.assertEqual(
b"".join(fd.received),
b"%(len)d:%(data)s,%(len2)d:%(data2)s," % {
b"len": len(b"hello"), b"data": b"hello",
Expand All @@ -59,7 +59,7 @@ def test_netstringToString(self):
fd = FakeDrain()
ff.flowTo(series(netstringsToBytes())).flowTo(fd)
ff.drain.receive(b"1:x,2:yz,3:")
self.assertEquals(fd.received, [b"x", b"yz"])
self.assertEqual(fd.received, [b"x", b"yz"])



Expand All @@ -77,7 +77,7 @@ def splitALine(newline):
fd = FakeDrain()
ff.flowTo(series(bytesToLines())).flowTo(fd)
ff.drain.receive(newline.join([b"alpha", b"beta", b"gamma"]))
self.assertEquals(fd.received, [b"alpha", b"beta"])
self.assertEqual(fd.received, [b"alpha", b"beta"])
splitALine(b"\n")
splitALine(b"\r\n")

Expand All @@ -91,7 +91,7 @@ def test_linesToBytes(self):
ff.flowTo(series(linesToBytes())).flowTo(fd)
ff.drain.receive(b"hello")
ff.drain.receive(b"world")
self.assertEquals(b"".join(fd.received), b"hello\r\nworld\r\n")
self.assertEqual(b"".join(fd.received), b"hello\r\nworld\r\n")


def test_rawMode(self):
Expand Down Expand Up @@ -125,7 +125,7 @@ def received(self, data):
ff.drain.receive(b"hello\r\nworld\r\nswitch 10\r\nabcde\r\nfgh"
# + '\r\nagain\r\n'
)
self.assertEquals(b"".join(Switchee.datums), b"abcde\r\nfgh")
self.assertEqual(b"".join(Switchee.datums), b"abcde\r\nfgh")


def test_switchingWithMoreDataToDeliver(self):
Expand All @@ -148,8 +148,8 @@ def received(self, line):
cc = series(lines, Switcher())
ff.flowTo(cc).flowTo(fd1)
ff.drain.receive(b'something\r\nswitch\r\n7:hello\r\n,5:world,')
self.assertEquals(fd1.received, [b"something"])
self.assertEquals(fd2.received, [b'hello\r\n', b'world'])
self.assertEqual(fd1.received, [b"something"])
self.assertEqual(fd2.received, [b'hello\r\n', b'world'])



Expand All @@ -167,7 +167,7 @@ def test_prefixIn(self):
fd = FakeDrain()
ff.flowTo(series(packed)).flowTo(fd)
ff.drain.receive(b"\x0812345678\x02")
self.assertEquals(fd.received, [b"12345678"])
self.assertEqual(fd.received, [b"12345678"])


def test_prefixOut(self):
Expand All @@ -181,4 +181,4 @@ def test_prefixOut(self):
ff.drain.receive(b'a')
ff.drain.receive(b'bc')
ff.drain.receive(b'def')
self.assertEquals(fd.received, [b'\x01a', b'\x02bc', b'\x03def'])
self.assertEqual(fd.received, [b'\x01a', b'\x02bc', b'\x03def'])
2 changes: 1 addition & 1 deletion tubes/test/test_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_specifiedTypeChecking(self):
correctFount = FakeFount(Routed(IFakeInput))
incorrectFount = FakeFount(Routed(IFakeOutput))
self.assertRaises(TypeError, incorrectFount.flowTo, router.drain)
self.assertEquals(None, correctFount.flowTo(router.drain))
self.assertEqual(None, correctFount.flowTo(router.drain))



Expand Down
38 changes: 19 additions & 19 deletions tubes/test/test_tube.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_tubeStarted(self):
"""

self.ff.flowTo(series(Starter(), self.fd))
self.assertEquals(self.fd.received, ["greeting"])
self.assertEqual(self.fd.received, ["greeting"])


def test_startedFlowingToAnother(self):
Expand Down Expand Up @@ -221,14 +221,14 @@ def stopped(self, reason):
yield "conclusion"

self.ff.flowTo(series(Ender(), self.fd))
self.assertEquals(reasons, [])
self.assertEquals(self.fd.received, [])
self.assertEqual(reasons, [])
self.assertEqual(self.fd.received, [])

stopReason = Failure(ZeroDivisionError())

self.ff.drain.flowStopped(stopReason)
self.assertEquals(self.fd.received, ["conclusion"])
self.assertEquals(len(reasons), 1)
self.assertEqual(self.fd.received, ["conclusion"])
self.assertEqual(len(reasons), 1)
self.assertIdentical(reasons[0].type, ZeroDivisionError)

self.assertEqual(self.fd.stopped, [stopReason])
Expand Down Expand Up @@ -264,7 +264,7 @@ def received(self, data):
self.ff.flowTo(diverter).flowTo(series(Switcher(), fakeDrain))
self.ff.drain.receive("switch")
self.ff.drain.receive("to switchee")
self.assertEquals(fakeDrain.received, ["switched to switchee"])
self.assertEqual(fakeDrain.received, ["switched to switchee"])


def test_tubeDivertingReassembly(self):
Expand Down Expand Up @@ -467,7 +467,7 @@ def test_flowToNoneInitialNoOp(self):
any other invocations of L{_SiphonFount.flowTo}.
"""
siphonFount = self.ff.flowTo(self.siphonDrain)
self.assertEquals(siphonFount.drain, None)
self.assertEqual(siphonFount.drain, None)
siphonFount.flowTo(None)


Expand Down Expand Up @@ -505,7 +505,7 @@ def received(self, data):
ff.bufferUp("after")
nf = ff.flowTo(firstDrain)
nf.flowTo(fakeDrain)
self.assertEquals(self.fd.received, ["before", "switched after"])
self.assertEqual(self.fd.received, ["before", "switched after"])


def test_tubeDiverting_LotsOfStuffAtOnce(self):
Expand Down Expand Up @@ -548,7 +548,7 @@ def received(self, data):

self.ff.flowTo(firstDrain).flowTo(fakeDrain)
self.ff.drain.receive(["before", "switch", "after"])
self.assertEquals(self.fd.received, ["before", "switched after"])
self.assertEqual(self.fd.received, ["before", "switched after"])


def test_flowingFromFirst(self):
Expand Down Expand Up @@ -610,7 +610,7 @@ def test_receiveIterableDeliversDownstream(self):
"""
self.ff.flowTo(series(PassthruTube())).flowTo(self.fd)
self.ff.drain.receive(7)
self.assertEquals(self.fd.received, [7])
self.assertEqual(self.fd.received, [7])


def test_receiveCallsTubeReceived(self):
Expand All @@ -619,7 +619,7 @@ def test_receiveCallsTubeReceived(self):
tube.
"""
self.siphonDrain.receive("one-item")
self.assertEquals(self.tube.allReceivedItems, ["one-item"])
self.assertEqual(self.tube.allReceivedItems, ["one-item"])


def test_flowToWillNotResumeFlowPausedInFlowingFrom(self):
Expand Down Expand Up @@ -742,9 +742,9 @@ def test_stopFlow(self):
fount.
"""
self.ff.flowTo(series(self.siphonDrain, self.fd))
self.assertEquals(self.ff.flowIsStopped, False)
self.assertEqual(self.ff.flowIsStopped, False)
self.fd.fount.stopFlow()
self.assertEquals(self.ff.flowIsStopped, True)
self.assertEqual(self.ff.flowIsStopped, True)


def test_stopFlowInterruptsStarted(self):
Expand Down Expand Up @@ -813,7 +813,7 @@ def test_stopFlowBeforeFlowBegins(self):
partially = series(self.siphonDrain, self.fd)
self.fd.fount.stopFlow()
self.ff.flowTo(partially)
self.assertEquals(self.ff.flowIsStopped, True)
self.assertEqual(self.ff.flowIsStopped, True)


def test_stopFlowWhileStartingFlow(self):
Expand Down Expand Up @@ -897,9 +897,9 @@ def started(self):
siphonDrain = series(UnstartableTube(), fd)
ff.flowTo(siphonDrain)
errors = self.flushLoggedErrors(ZeroDivisionError)
self.assertEquals(len(errors), 1)
self.assertEquals(ff.flowIsStopped, True)
self.assertEquals(fd.stopped[0].type, ZeroDivisionError)
self.assertEqual(len(errors), 1)
self.assertEqual(ff.flowIsStopped, True)
self.assertEqual(fd.stopped[0].type, ZeroDivisionError)


def test_startedRaisesNoDrain(self):
Expand All @@ -917,8 +917,8 @@ def started(self):
siphonDrain = series(UnstartableTube())
ff.flowTo(siphonDrain)
errors = self.flushLoggedErrors(ZeroDivisionError)
self.assertEquals(len(errors), 1)
self.assertEquals(ff.flowIsStopped, True)
self.assertEqual(len(errors), 1)
self.assertEqual(ff.flowIsStopped, True)



Expand Down
24 changes: 12 additions & 12 deletions tubes/test/test_undefer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def received(self, data):
self.ff.flowTo(series(SucceedingTube(),
deferredToResult())).flowTo(fakeDrain)
self.ff.drain.receive("hello")
self.assertEquals(self.fd.received, ["olleh"])
self.assertEqual(self.fd.received, ["olleh"])


def test_tubeYieldsUnfiredDeferred(self):
Expand All @@ -63,11 +63,11 @@ def received(self, data):
self.ff.flowTo(series(WaitingTube(),
deferredToResult())).flowTo(fakeDrain)
self.ff.drain.receive("ignored")
self.assertEquals(self.fd.received, [])
self.assertEqual(self.fd.received, [])

d.callback("hello")

self.assertEquals(self.fd.received, ["hello"])
self.assertEqual(self.fd.received, ["hello"])


def test_tubeYieldsMultipleDeferreds(self):
Expand All @@ -90,11 +90,11 @@ def received(self, data):
self.ff.flowTo(series(MultiDeferredTube(),
deferredToResult())).flowTo(fakeDrain)
self.ff.drain.receive("ignored")
self.assertEquals(self.fd.received, [])
self.assertEqual(self.fd.received, [])

d.callback("hello")

self.assertEquals(self.fd.received, ["hello", "goodbye"])
self.assertEqual(self.fd.received, ["hello", "goodbye"])


def test_tubeYieldedDeferredFiresWhileFlowIsPaused(self):
Expand All @@ -118,10 +118,10 @@ def received(self, data):
anPause = self.fd.fount.pauseFlow()

d.callback("hello")
self.assertEquals(self.fd.received, [])
self.assertEqual(self.fd.received, [])

anPause.unpause()
self.assertEquals(self.fd.received, ["hello"])
self.assertEqual(self.fd.received, ["hello"])


def test_tubeStoppedDeferredly(self):
Expand All @@ -139,20 +139,20 @@ def stopped(self, reason):
yield conclusion

self.ff.flowTo(series(SlowEnder(), deferredToResult(), self.fd))
self.assertEquals(reasons, [])
self.assertEquals(self.fd.received, [])
self.assertEqual(reasons, [])
self.assertEqual(self.fd.received, [])

stopReason = Failure(ZeroDivisionError())

self.ff.drain.flowStopped(stopReason)
self.assertEquals(self.fd.received, [])
self.assertEquals(len(reasons), 1)
self.assertEqual(self.fd.received, [])
self.assertEqual(len(reasons), 1)
self.assertIdentical(reasons[0].type, ZeroDivisionError)
self.assertEqual(self.fd.stopped, [])

conclusion.callback("conclusion")
# Now it's really done.
self.assertEquals(self.fd.received, ["conclusion"])
self.assertEqual(self.fd.received, ["conclusion"])
self.assertEqual(self.fd.stopped, [stopReason])


Expand Down

0 comments on commit b74680b

Please sign in to comment.