Fix warning regarding ABC import from collections

This commit is contained in:
Karthikeyan Singaravelan 2020-09-19 06:58:24 +00:00 committed by Nyall Dawson
parent 776768eb9f
commit 4adb937ced
2 changed files with 13 additions and 5 deletions

View File

@ -29,7 +29,11 @@ import tempfile
import inspect
import time
import test_qgsdelimitedtextprovider_wanted as want # NOQA
import collections
try:
from collections.abc import Callable
except ImportError:
from collections import Callable
rebuildTests = 'REBUILD_DELIMITED_TEXT_TESTS' in os.environ
@ -305,11 +309,11 @@ class TestQgsDelimitedTextProviderOther(unittest.TestCase):
for nr, r in enumerate(requests):
if verbose:
print(("Processing request", nr + 1, repr(r)))
if isinstance(r, collections.Callable):
if isinstance(r, Callable):
r(layer)
if verbose:
print("Request function executed")
if isinstance(r, collections.Callable):
if isinstance(r, Callable):
continue
rfields, rtypes, rdata = self.layerData(layer, r, nr * 1000)
if len(rfields) > len(fields):

View File

@ -11,7 +11,6 @@ the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
"""
import collections
__author__ = 'Larry Shaffer'
__date__ = '07/09/2013'
@ -25,6 +24,11 @@ import datetime
import glob
import shutil
try:
from collections.abc import Callable
except ImportError:
from collections import Callable
from qgis.PyQt.QtCore import QSize, qDebug, Qt
from qgis.PyQt.QtGui import QFont, QColor
@ -267,7 +271,7 @@ class TestQgsPalLabeling(unittest.TestCase):
value = getattr(lyr, attr)
if isinstance(value, (QgsGeometry, QgsStringReplacementCollection, QgsCoordinateTransform)):
continue # ignore these objects
if not isinstance(value, collections.Callable):
if not isinstance(value, Callable):
res[attr] = value
return res