Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/175319

Change subject: Fix a couple of warnings in the test suite code
......................................................................

Fix a couple of warnings in the test suite code

* Use TestCase.assertEqual in lieu of the deprecated TestCase.assertEquals.
* Explicitly close the wsgiref server's socket.

Change-Id: I285c188b60d2cce580f9568f818b10bec2572383
---
M server/tests/test_compat.py
M server/tests/test_jrm.py
M server/tests/test_streams.py
3 files changed, 12 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EventLogging 
refs/changes/19/175319/1

diff --git a/server/tests/test_compat.py b/server/tests/test_compat.py
index dc1f5eb..4cbb2fb 100644
--- a/server/tests/test_compat.py
+++ b/server/tests/test_compat.py
@@ -30,6 +30,7 @@
             return [self.resp]
         httpd = wsgiref.simple_server.make_server('127.0.0.1', 44080, app)
         httpd.handle_request()
+        httpd.socket.close()
 
 
 class UriSplitTestCase(unittest.TestCase):
@@ -38,8 +39,8 @@
     def test_urisplit(self):
         uri = 'tcp://127.0.0.1:8600/?q=1#f=2'
         parts = eventlogging.urisplit(uri)
-        self.assertEquals(parts.query, 'q=1')
-        self.assertEquals(parts.fragment, 'f=2')
+        self.assertEqual(parts.query, 'q=1')
+        self.assertEqual(parts.fragment, 'f=2')
 
 
 class HttpGetTestCase(unittest.TestCase):
@@ -51,4 +52,4 @@
         server = SingleServingHttpd('secret')
         server.start()
         response = eventlogging.http_get('http://127.0.0.1:44080')
-        self.assertEquals(response, 'secret')
+        self.assertEqual(response, 'secret')
diff --git a/server/tests/test_jrm.py b/server/tests/test_jrm.py
index 82b5d3c..87d6b7b 100644
--- a/server/tests/test_jrm.py
+++ b/server/tests/test_jrm.py
@@ -34,7 +34,7 @@
         results = self.engine.execute(s)
         row = results.fetchone()
         # see columns with print table.c
-        self.assertEquals(row['clientIp'], self.event['clientIp'])
+        self.assertEqual(row['clientIp'], self.event['clientIp'])
 
     def test_column_names(self):
         """Generated tables contain columns for each relevant field."""
@@ -102,7 +102,7 @@
         results = self.engine.execute(s)
         # the number of records in table must be the list size
         rows = results.fetchall()
-        self.assertEquals(len(rows), 2)
+        self.assertEqual(len(rows), 2)
 
     def test_insertion_of_multiple_events_with_a_duplicate(self):
         """"If an insert with multiple events includes
@@ -121,7 +121,7 @@
         s = sqlalchemy.sql.select([table])
         results = self.engine.execute(s)
         rows = results.fetchall()
-        self.assertEquals(len(rows), 2)
+        self.assertEqual(len(rows), 2)
 
     def test_event_queue_is_empty(self):
         """An empty event queue is handled well
@@ -145,7 +145,7 @@
         for k, events in batches:
             uniquekeys.append(k)
         # we should have stored one key as events can be batched together
-        self.assertEquals(len(uniquekeys), 1)
+        self.assertEqual(len(uniquekeys), 1)
 
     def test_grouping_of_events_separately(self):
         """Events belonging to the same schema with a different
@@ -167,7 +167,7 @@
         for k, events in batches:
             uniquekeys.append(k)
         # we should have stored two keys as events cannot be grouped together
-        self.assertEquals(len(uniquekeys), 2)
+        self.assertEqual(len(uniquekeys), 2)
 
     def test_insert_events_with_different_set_of_optional_fields(self):
         """Events belonging to the same schema with a different
@@ -184,4 +184,4 @@
         results = self.engine.execute(s)
         # the number of records in table must be the list size
         rows = results.fetchall()
-        self.assertEquals(len(rows), 2)
+        self.assertEqual(len(rows), 2)
diff --git a/server/tests/test_streams.py b/server/tests/test_streams.py
index 984bc4f..50dde49 100644
--- a/server/tests/test_streams.py
+++ b/server/tests/test_streams.py
@@ -34,6 +34,8 @@
         time.sleep(0.05)
         pub.send_unicode(message)
 
+    pub.close()
+
 
 class ZmqTestCase(TimeoutTestMixin, unittest.TestCase):
     """Test case for ZeroMQ-related functionality."""

-- 
To view, visit https://gerrit.wikimedia.org/r/175319
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I285c188b60d2cce580f9568f818b10bec2572383
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EventLogging
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to