Skip to content

Commit

Permalink
Fix deprecated assertions
Browse files Browse the repository at this point in the history
Python 3.1 and Python 3.2 deprecated a large amount of assertions, and
have finally been removed in Python 3.12. Move to the "new" function
names.

Fixes pyga#80
  • Loading branch information
s-t-e-v-e-n-k committed Jan 9, 2024
1 parent c89b3f0 commit f0ad2f6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ometa/test/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def test_markAsTree(self):
x = t.Rule("foo", t.List(
t.Exactly("x")))
g = t.Grammar("TestGrammar", True, [x])
self.assert_("\n tree = True\n" in writePython(g, ""))
self.assertIn("\n tree = True\n", writePython(g, ""))


def test_rule(self):
Expand Down
12 changes: 6 additions & 6 deletions ometa/test/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_parserPassed(self):
def test_connectionEstablishes(self):
"""prepareParsing is called on the receiver after connection establishment."""
self.protocol.makeConnection(None)
self.assert_(self.protocol.receiver.connected)
self.assertTrue(self.protocol.receiver.connected)

def test_basicParsing(self):
"""Rules can be parsed multiple times for the same effect."""
Expand Down Expand Up @@ -161,10 +161,10 @@ def test_parseFailure(self):
transport = FakeTransport()
self.protocol.makeConnection(transport)
self.protocol.dataReceived('b')
self.failIfEqual(self.protocol.receiver.lossReason, None)
self.assertIsNotNone(self.protocol.receiver.lossReason)
self.assertTrue(
isinstance(self.protocol.receiver.lossReason.value, ParseError))
self.assert_(transport.aborted)
self.assertTrue(transport.aborted)

def test_exceptionsRaisedFromReceiver(self):
"""
Expand All @@ -174,10 +174,10 @@ def test_exceptionsRaisedFromReceiver(self):
transport = FakeTransport()
self.protocol.makeConnection(transport)
self.protocol.dataReceived('e')
self.failIfEqual(self.protocol.receiver.lossReason, None)
self.assertIsNotNone(self.protocol.receiver.lossReason)
self.assertTrue(
isinstance(self.protocol.receiver.lossReason.value, SomeException))
self.assert_(transport.aborted)
self.assertTrue(transport.aborted)

def test_dataIgnoredAfterDisconnection(self):
"""After connectionLost is called, all incoming data is ignored."""
Expand All @@ -187,4 +187,4 @@ def test_dataIgnoredAfterDisconnection(self):
self.protocol.connectionLost(reason)
self.protocol.dataReceived('d')
self.assertEqual(self.protocol.receiver.lossReason, reason)
self.assert_(not transport.aborted)
self.assertFalse(transport.aborted)
4 changes: 2 additions & 2 deletions ometa/test/test_pymeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -1138,8 +1138,8 @@ def test_brokenGrammar(self):
"""
e = self.assertRaises(ParseError, OMeta.makeGrammar, grammar,
"Foo")
self.assertEquals(e.position, 57)
self.assertEquals(e.error, [("message", "end of input")])
self.assertEqual(e.position, 57)
self.assertEqual(e.error, [("message", "end of input")])


def test_subclassing(self):
Expand Down
4 changes: 2 additions & 2 deletions ometa/test/test_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def test_exactlyFail(self):
data = "foo"
o = OMetaBase(data)
exc = self.assertRaises(ParseError, o.rule_exactly, "g")
self.assertEquals(exc.args[1], expected(None, "g"))
self.assertEquals(exc.args[0], 0)
self.assertEqual(exc.args[1], expected(None, "g"))
self.assertEqual(exc.args[0], 0)



Expand Down

0 comments on commit f0ad2f6

Please sign in to comment.