Commit 453d760d authored by Tanner Prestegard's avatar Tanner Prestegard

adding in compatibility for Python 3.5, 3.6, and 3.7

parent 4976f5b5
......@@ -373,7 +373,7 @@ class TestMain(TestGraceDb):
log.addHandler(handler)
try:
message = "Message is {0}".format(random.random())
log.warn(message)
log.warning(message)
finally:
log.removeHandler(handler)
finally:
......
......@@ -16,10 +16,11 @@
# You should have received a copy of the GNU General Public License
# along with gracedb. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from builtins import map
from collections import defaultdict
import datetime
import os
from six import iteritems
import six
from six.moves import range
import unittest
......@@ -376,7 +377,7 @@ class TestSuperevents(TestGraceDb):
# Test file contents
file_from_server = response.read()
file_handler = open(upload, 'r')
file_handler = open(upload, 'rb')
file_from_disk = file_handler.read()
file_handler.close()
self.assertEqual(file_from_server, file_from_disk)
......@@ -395,7 +396,9 @@ class TestSuperevents(TestGraceDb):
self.assertEqual(response.status, 201)
# Test response data
self.assertItemsEqual(tags, data['tag_names'])
# We use six here since assertItemsEqual in Python 2.7 is
# called assertCountEqual in Python 3.3+
six.assertCountEqual(self, tags, data['tag_names'])
self.assertEqual(data['comment'], msg)
def test_log_tag_and_untag(self):
......@@ -431,7 +434,9 @@ class TestSuperevents(TestGraceDb):
self.assertEqual(response.status, 200)
# Test log tags
self.assertItemsEqual([tag], log_data['tag_names'])
# We use six here since assertItemsEqual in Python 2.7 is
# called assertCountEqual in Python 3.3+
six.assertCountEqual(self, [tag], log_data['tag_names'])
# Remove tag from log
response = self._gracedb.removeTag(self._superevent, data['N'], tag)
......@@ -499,8 +504,8 @@ class TestSuperevents(TestGraceDb):
dec_list = [5, 6, 7, 8]
dec_width_list = [0.7]*len(dec_list)
now = datetime.datetime.now()
start_time_list = map(lambda i:
(now + datetime.timedelta(seconds=i)).isoformat(), [0, 1, 2, 3])
start_time_list = list(map(lambda i:
(now + datetime.timedelta(seconds=i)).isoformat(), [0, 1, 2, 3]))
duration_list = [1]*len(start_time_list)
comment = "test comment"
response = self._gracedb.writeEMObservation(self._superevent, emgroup,
......@@ -755,7 +760,7 @@ class TestSuperevents(TestGraceDb):
for p in data:
group_perms[p['group']].append(p['permission'])
# Check contents
for group, perms in iteritems(group_perms):
for group, perms in six.iteritems(group_perms):
if (group == 'public_users'):
self.assertEqual(len(perms), 1)
self.assertIn('view_superevent', perms)
......@@ -774,7 +779,7 @@ class TestSuperevents(TestGraceDb):
for p in data:
group_perms[p['group']].append(p['permission'])
# Check contents
for group, perms in iteritems(group_perms):
for group, perms in six.iteritems(group_perms):
if (group == 'public_users'):
self.assertEqual(len(perms), 1)
self.assertIn('view_superevent', perms)
......
......@@ -53,7 +53,7 @@ setup(
#provides = ['ligo.gracedb'],
packages = find_packages(),
install_requires = ['six'],
install_requires = ['future', 'six'],
tests_require = tests_require,
package_data = { 'ligo.gracedb.test' : ['data/*', 'test.sh', 'README'] },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment