ltmpl: Update to use collections.abc

This commit is contained in:
Brian C. Lane 2020-01-14 08:40:03 -08:00
parent b86926e275
commit 0d3cff0dde
2 changed files with 4 additions and 4 deletions

View File

@ -39,7 +39,7 @@ from mako.exceptions import text_error_template
import sys, traceback import sys, traceback
import struct import struct
import dnf import dnf
import collections import collections.abc
class LoraxTemplate(object): class LoraxTemplate(object):
def __init__(self, directories=None): def __init__(self, directories=None):
@ -163,7 +163,7 @@ class TemplateRunner(object):
try: try:
# grab the method named in cmd and pass it the given arguments # grab the method named in cmd and pass it the given arguments
f = getattr(self, cmd, None) f = getattr(self, cmd, None)
if cmd[0] == '_' or cmd == 'run' or not isinstance(f, collections.Callable): if cmd[0] == '_' or cmd == 'run' or not isinstance(f, collections.abc.Callable):
raise ValueError("unknown command %s" % cmd) raise ValueError("unknown command %s" % cmd)
f(*args) f(*args)
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except

View File

@ -52,13 +52,13 @@ class CliUtilitiesTest(unittest.TestCase):
"""Test a result with no status and no error fields""" """Test a result with no status and no error fields"""
result = {"foo": "bar"} result = {"foo": "bar"}
self.assertEqual(handle_api_result(result, show_json=False), (0, False)) self.assertEqual(handle_api_result(result, show_json=False), (0, False))
self.assertTrue(handle_api_result(result, show_json=False)[0] is 0) self.assertTrue(handle_api_result(result, show_json=False)[0] == 0)
def test_api_result_2(self): def test_api_result_2(self):
"""Test a result with errors=[{"id": INVALID_CHARS, "msg": "some error"}], and no status field""" """Test a result with errors=[{"id": INVALID_CHARS, "msg": "some error"}], and no status field"""
result = {"foo": "bar", "errors": [{"id": INVALID_CHARS, "msg": "some error"}]} result = {"foo": "bar", "errors": [{"id": INVALID_CHARS, "msg": "some error"}]}
self.assertEqual(handle_api_result(result, show_json=False), (1, False)) self.assertEqual(handle_api_result(result, show_json=False), (1, False))
self.assertTrue(handle_api_result(result, show_json=False)[0] is 1) self.assertTrue(handle_api_result(result, show_json=False)[0] == 1)
def test_api_result_3(self): def test_api_result_3(self):
"""Test a result with status=True, and errors=[]""" """Test a result with status=True, and errors=[]"""