]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Upgrade Python syntax with pyupgrade https://github.com/asottile/pyupgrade 334/head
authorHugo <hugovk@users.noreply.github.com>
Thu, 6 Sep 2018 11:18:29 +0000 (14:18 +0300)
committerHugo <hugovk@users.noreply.github.com>
Thu, 6 Sep 2018 11:18:29 +0000 (14:18 +0300)
27 files changed:
dns/dnssec.py
dns/edns.py
dns/exception.py
dns/flags.py
dns/ipv6.py
dns/name.py
dns/opcode.py
dns/rcode.py
dns/rdata.py
dns/rdataclass.py
dns/rdataset.py
dns/rdatatype.py
dns/rdtypes/ANY/GPOS.py
dns/rdtypes/ANY/HINFO.py
dns/rdtypes/ANY/ISDN.py
dns/rdtypes/ANY/LOC.py
dns/rdtypes/ANY/NSEC.py
dns/rdtypes/ANY/RP.py
dns/rdtypes/dnskeybase.py
dns/rdtypes/txtbase.py
dns/resolver.py
dns/zone.py
examples/zonediff.py
setup.py
tests/test_exceptions.py
tests/test_rdtypeanydnskey.py
tests/test_rdtypeanyloc.py

index 1bd422e3cf1cb7b79e4fe22f37378b159cd5eac5..5426373fe64e5120f65c81270783b802c4e31c84 100644 (file)
@@ -87,7 +87,7 @@ _algorithm_by_text = {
 # cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
 # would cause the mapping not to be true inverse.
 
-_algorithm_by_value = dict((y, x) for x, y in _algorithm_by_text.items())
+_algorithm_by_value = {y: x for x, y in _algorithm_by_text.items()}
 
 
 def algorithm_from_text(text):
index 22104d8702ff67a3f6f014d032ffc2794d53f79e..487e67eb062acb44caaa0181aeb283c1c8fc7d28 100644 (file)
@@ -197,8 +197,8 @@ class ECSOption(Option):
             self.addrdata = self.addrdata[:-1] + last
 
     def to_text(self):
-        return "ECS %s/%s scope/%s" % (self.address, self.srclen,
-                                       self.scopelen)
+        return "ECS {}/{} scope/{}".format(self.address, self.srclen,
+                                           self.scopelen)
 
     def to_wire(self, file):
         file.write(struct.pack('!H', self.family))
index 89aee9c76c3da0e5487f82f8e77b52da155971f9..57f2bc1211cac2d69ddc18247fa0b776352166aa 100644 (file)
@@ -122,5 +122,5 @@ class TooBig(DNSException):
 
 class Timeout(DNSException):
     """The DNS operation timed out."""
-    supp_kwargs = set(['timeout'])
+    supp_kwargs = {'timeout'}
     fmt = "The DNS operation timed out after {timeout} seconds"
index f9a62b3625c7d9ac8387666554dc1c80e0bab050..f6e30e2f072bd450cc889342163969c74260258f 100644 (file)
@@ -56,9 +56,9 @@ _edns_by_text = {
 # cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
 # would cause the mappings not to be true inverses.
 
-_by_value = dict((y, x) for x, y in _by_text.items())
+_by_value = {y: x for x, y in _by_text.items()}
 
-_edns_by_value = dict((y, x) for x, y in _edns_by_text.items())
+_edns_by_value = {y: x for x, y in _edns_by_text.items()}
 
 
 def _order_flags(table):
index 49ef5562e3911bf78aece03111abe789ea880adb..db1e9c9a00f8f8bbd67a03f8d5c73db9fca6e722 100644 (file)
@@ -117,8 +117,9 @@ def inet_aton(text):
     m = _v4_ending.match(text)
     if not m is None:
         b = bytearray(dns.ipv4.inet_aton(m.group(2)))
-        text = (u"%s:%02x%02x:%02x%02x" % (m.group(1).decode(), b[0], b[1],
-                                           b[2], b[3])).encode()
+        text = (u"{}:{:02x}{:02x}:{:02x}{:02x}".format(m.group(1).decode(),
+                                                       b[0], b[1], b[2],
+                                                       b[3])).encode()
     #
     # Try to turn '::<whatever>' into ':<whatever>'; if no match try to
     # turn '<whatever>::' into '<whatever>:'
index 9764de5e78d771e07474530cab2f3c367f33bf9b..2b159b4c296489ce8198c97b9566019ec8c23d0f 100644 (file)
@@ -98,7 +98,7 @@ class NoIDNA2008(dns.exception.DNSException):
 class IDNAException(dns.exception.DNSException):
     """IDNA processing raised an exception."""
 
-    supp_kwargs = set(['idna_exception'])
+    supp_kwargs = {'idna_exception'}
     fmt = "IDNA processing exception: {idna_exception}"
 
 
index 5dcd2abffc5b56d86c233cf52faffe580bd555a0..249e359cd9891ba8cde61217481f39af69d8748c 100644 (file)
@@ -40,7 +40,7 @@ _by_text = {
 # cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
 # would cause the mapping not to be true inverse.
 
-_by_value = dict((y, x) for x, y in _by_text.items())
+_by_value = {y: x for x, y in _by_text.items()}
 
 
 class UnknownOpcode(dns.exception.DNSException):
index eb4d1d6b8ac78ef4036eb12e4dbc37bb925123c5..4d564c710c399cc1166bfb43208b0fb835330287 100644 (file)
@@ -62,7 +62,7 @@ _by_text = {
 # cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
 # would cause the mapping not to be a true inverse.
 
-_by_value = dict((y, x) for x, y in _by_text.items())
+_by_value = {y: x for x, y in _by_text.items()}
 
 
 class UnknownRcode(dns.exception.DNSException):
index 5123a24138b1ce61828dd01c3b25b8d274e1d684..06c4722cc02ec25312985f32749e7d962e052d35 100644 (file)
@@ -427,7 +427,7 @@ def from_wire(rdclass, rdtype, wire, current, rdlen, origin=None):
 
 class RdatatypeExists(dns.exception.DNSException):
     """DNS rdatatype already exists."""
-    supp_kwargs = set(['rdclass', 'rdtype'])
+    supp_kwargs = {'rdclass', 'rdtype'}
     fmt = "The rdata type with class {rdclass} and rdtype {rdtype} " + \
         "already exists."
 
index 916dc615c4b2a116cc105802bda7bd9fa732a3da..d3d883d6cdecb63079e5d69510df9d2e6a09bf70 100644 (file)
@@ -39,7 +39,7 @@ _by_text = {
 # cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
 # would cause the mapping not to be true inverse.
 
-_by_value = dict((y, x) for x, y in _by_text.items())
+_by_value = {y: x for x, y in _by_text.items()}
 
 # Now that we've built the inverse map, we can add class aliases to
 # the _by_text mapping.
index bd8cfab7c467480d9dc6638eeaca98c4bd936ae5..96f0661988f454c0a334cf3fcf3c3269f1992d7c 100644 (file)
@@ -204,9 +204,9 @@ class Rdataset(dns.set.Set):
             # some dynamic updates, so we don't need to print out the TTL
             # (which is meaningless anyway).
             #
-            s.write(u'%s%s%s %s\n' % (ntext, pad,
-                                      dns.rdataclass.to_text(rdclass),
-                                      dns.rdatatype.to_text(self.rdtype)))
+            s.write(u'{}{}{} {}\n'.format(ntext, pad,
+                                          dns.rdataclass.to_text(rdclass),
+                                          dns.rdatatype.to_text(self.rdtype)))
         else:
             for rd in self:
                 s.write(u'%s%s%d %s %s %s\n' %
index c9bf599a08f0aba07bbf117f2c2ab860f8260a0b..94cbb736686c635ad6c4ca1ea2da549a8f34fa6b 100644 (file)
@@ -167,7 +167,7 @@ _by_text = {
 # cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
 # would cause the mapping not to be true inverse.
 
-_by_value = dict((y, x) for x, y in _by_text.items())
+_by_value = {y: x for x, y in _by_text.items()}
 
 _metatypes = {
     OPT: True
index a359a77123127a59e0b7409dae4b21bfbb7485c6..4f22818f7a2ca16ab7e09439f49d3c6cef12f393 100644 (file)
@@ -80,7 +80,7 @@ class GPOS(dns.rdata.Rdata):
         self.altitude = altitude
 
     def to_text(self, origin=None, relativize=True, **kw):
-        return '%s %s %s' % (self.latitude.decode(),
+        return '{} {} {}'.format(self.latitude.decode(),
                              self.longitude.decode(),
                              self.altitude.decode())
 
index e5a1bea3dd95ac35c9bb60b60329f0e9073b59c5..1e0620a66a21c13a66421a494c05e9f60fb41fc7 100644 (file)
@@ -45,8 +45,8 @@ class HINFO(dns.rdata.Rdata):
             self.os = os
 
     def to_text(self, origin=None, relativize=True, **kw):
-        return '"%s" "%s"' % (dns.rdata._escapify(self.cpu),
-                              dns.rdata._escapify(self.os))
+        return '"{}" "{}"'.format(dns.rdata._escapify(self.cpu),
+                                  dns.rdata._escapify(self.os))
 
     @classmethod
     def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True):
index da2ae3af3abec3b902f191210df885d159e0eb42..e264814b260e999ed5cb9edc0f387e49085df1d9 100644 (file)
@@ -46,7 +46,7 @@ class ISDN(dns.rdata.Rdata):
 
     def to_text(self, origin=None, relativize=True, **kw):
         if self.subaddress:
-            return '"%s" "%s"' % (dns.rdata._escapify(self.address),
+            return '"{}" "{}"'.format(dns.rdata._escapify(self.address),
                                   dns.rdata._escapify(self.subaddress))
         else:
             return '"%s"' % dns.rdata._escapify(self.address)
index b433da9487f2209de7a47713de764321e5ed8cfb..cd5e3fb2cba9482f97988fc2321deba7e75e8788 100644 (file)
@@ -156,7 +156,7 @@ class LOC(dns.rdata.Rdata):
         if self.size != _default_size or \
             self.horizontal_precision != _default_hprec or \
                 self.vertical_precision != _default_vprec:
-            text += " %0.2fm %0.2fm %0.2fm" % (
+            text += " {:0.2f}m {:0.2f}m {:0.2f}m".format(
                 self.size / 100.0, self.horizontal_precision / 100.0,
                 self.vertical_precision / 100.0
             )
index dfe96859ff421ff2f4fa43ad7473bc8876a31a3d..470a49d85c0784454d61d5dbae73d8a2c7710ffa 100644 (file)
@@ -50,7 +50,7 @@ class NSEC(dns.rdata.Rdata):
                         bits.append(dns.rdatatype.to_text(window * 256 +
                                                           i * 8 + j))
             text += (' ' + ' '.join(bits))
-        return '%s%s' % (next, text)
+        return '{}{}'.format(next, text)
 
     @classmethod
     def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True):
index e9071c76342aafbbcd8c78b10e93dae894135ba9..5b701d96acd81e6f3819323753d9d6901e0a79bf 100644 (file)
@@ -39,7 +39,7 @@ class RP(dns.rdata.Rdata):
     def to_text(self, origin=None, relativize=True, **kw):
         mbox = self.mbox.choose_relativity(origin, relativize)
         txt = self.txt.choose_relativity(origin, relativize)
-        return "%s %s" % (str(mbox), str(txt))
+        return "{} {}".format(str(mbox), str(txt))
 
     @classmethod
     def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True):
index 85c4b23f01ce6c4327c196adf97215d78436c1f4..4f730ce3f2b80032fdc39ef9030e321f82cb5330 100644 (file)
@@ -38,7 +38,7 @@ _flag_by_text = {
 # We construct the inverse mapping programmatically to ensure that we
 # cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
 # would cause the mapping not to be true inverse.
-_flag_by_value = dict((y, x) for x, y in _flag_by_text.items())
+_flag_by_value = {y: x for x, y in _flag_by_text.items()}
 
 
 def flags_to_text_set(flags):
index aa341f1acdb91225b92028ca939d4cf3780bdbad..bb776094412518824f934b6f384528ad4fabbf03 100644 (file)
@@ -48,7 +48,7 @@ class TXTBase(dns.rdata.Rdata):
         txt = ''
         prefix = ''
         for s in self.strings:
-            txt += '%s"%s"' % (prefix, dns.rdata._escapify(s))
+            txt += '{}"{}"'.format(prefix, dns.rdata._escapify(s))
             prefix = ' '
         return txt
 
index b44431cc8cc761a0921678688fbfc2c0d5ad003c..b794d312b0e7d909ed42aaf348188a9f6ab6f68a 100644 (file)
@@ -47,7 +47,7 @@ if sys.platform == 'win32':
 
 class NXDOMAIN(dns.exception.DNSException):
     """The DNS query name does not exist."""
-    supp_kwargs = set(['qnames', 'responses'])
+    supp_kwargs = {'qnames', 'responses'}
     fmt = None  # we have our own __str__ implementation
 
     def _check_kwargs(self, qnames, responses=None):
@@ -71,7 +71,7 @@ class NXDOMAIN(dns.exception.DNSException):
         else:
             msg = 'The DNS query name does not exist'
         qnames = ', '.join(map(str, qnames))
-        return "%s: %s" % (msg, qnames)
+        return "{}: {}".format(msg, qnames)
 
     def canonical_name(self):
         if not 'qnames' in self.kwargs:
@@ -140,7 +140,7 @@ class NoAnswer(dns.exception.DNSException):
     """The DNS response does not contain an answer to the question."""
     fmt = 'The DNS response does not contain an answer ' + \
           'to the question: {query}'
-    supp_kwargs = set(['response'])
+    supp_kwargs = {'response'}
 
     def _fmt_kwargs(self, **kwargs):
         return super(NoAnswer, self)._fmt_kwargs(
@@ -158,12 +158,12 @@ class NoNameservers(dns.exception.DNSException):
 
     msg = "All nameservers failed to answer the query."
     fmt = "%s {query}: {errors}" % msg[:-1]
-    supp_kwargs = set(['request', 'errors'])
+    supp_kwargs = {'request', 'errors'}
 
     def _fmt_kwargs(self, **kwargs):
         srv_msgs = []
         for err in kwargs['errors']:
-            srv_msgs.append('Server %s %s port %s answered %s' % (err[0],
+            srv_msgs.append('Server {} {} port {} answered {}'.format(err[0],
                             'TCP' if err[1] else 'UDP', err[2], err[3]))
         return super(NoNameservers, self)._fmt_kwargs(
             query=kwargs['request'].question, errors='; '.join(srv_msgs))
index 2c7ea693ef1fde630590c0917d6d1f9672d10be9..65a1ea1377d864d05be33bc7f17b89baf880ac58 100644 (file)
@@ -715,7 +715,7 @@ class _MasterReader(object):
             # helpful filename:line info.
             (ty, va) = sys.exc_info()[:2]
             raise dns.exception.SyntaxError(
-                "caught exception %s: %s" % (str(ty), str(va)))
+                "caught exception {}: {}".format(str(ty), str(va)))
 
         if not self.default_ttl_known and isinstance(rd, dns.rdtypes.ANY.SOA.SOA):
             # The pre-RFC2308 and pre-BIND9 behavior inherits the zone default
index bfe4ee3dcda44b5a88784c45edf2b49bd3ce8337..b65f82824f15721adf494706a4c4f8b192836b9f 100755 (executable)
@@ -101,7 +101,7 @@ def format_changes_plain(oldf, # type: str
     Given 2 filenames and a list of changes from diff_zones, produce diff-like
     output. If ignore_ttl is True, TTL-only changes are not displayed"""
 
-    ret = "--- %s\n+++ %s\n" % (oldf, newf)
+    ret = "--- {}\n+++ {}\n".format(oldf, newf)
     for name, old, new in changes:
         ret += "@ %s\n" % name
         if not old:
@@ -244,34 +244,34 @@ The differences shown will be logical differences, not textual differences.
     else:
         if len(args) == 3:
             filename, oldr, newr = args
-            oldn = "%s:%s" % (oldr, filename)
-            newn = "%s:%s" % (newr, filename)
+            oldn = "{}:{}".format(oldr, filename)
+            newn = "{}:{}".format(newr, filename)
         else:
             filename, oldr = args
             newr = None
-            oldn = "%s:%s" % (oldr, filename)
+            oldn = "{}:{}".format(oldr, filename)
             newn = filename
 
     old, new = None, None
     oldz, newz = None, None
     if opts.use_bzr:
         old = _open(["bzr", "cat", "-r" + oldr, filename],
-                    "Unable to retrieve revision %s of %s" % (oldr, filename))
+                    "Unable to retrieve revision {} of {}".format(oldr, filename))
         if newr is not None:
             new = _open(["bzr", "cat", "-r" + newr, filename],
-                        "Unable to retrieve revision %s of %s" % (newr, filename))
+                        "Unable to retrieve revision {} of {}".format(newr, filename))
     elif opts.use_git:
         old = _open(["git", "show", oldn],
-                    "Unable to retrieve revision %s of %s" % (oldr, filename))
+                    "Unable to retrieve revision {} of {}".format(oldr, filename))
         if newr is not None:
             new = _open(["git", "show", newn],
-                        "Unable to retrieve revision %s of %s" % (newr, filename))
+                        "Unable to retrieve revision {} of {}".format(newr, filename))
     elif opts.use_rcs:
         old = _open(["co", "-q", "-p", "-r" + oldr, filename],
-                    "Unable to retrieve revision %s of %s" % (oldr, filename))
+                    "Unable to retrieve revision {} of {}".format(oldr, filename))
         if newr is not None:
             new = _open(["co", "-q", "-p", "-r" + newr, filename],
-                        "Unable to retrieve revision %s of %s" % (newr, filename))
+                        "Unable to retrieve revision {} of {}".format(newr, filename))
     if not opts.use_vc:
         old = _open(oldn, "Unable to open %s" % oldn)
     if not opts.use_vc or newr is None:
index 9a83a870fab4f9336b4627a522345ac9233ddbec..dbcedd10dad8f974bb0181ea53282cf4891183f5 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -49,7 +49,7 @@ direct manipulation of DNS zones, messages, names, and records.""",
     'packages' : ['dns', 'dns.rdtypes', 'dns.rdtypes.IN', 'dns.rdtypes.ANY'],
     'package_data' : {'dns': ['py.typed']},
     'download_url' : \
-    'http://www.dnspython.org/kits/%s/dnspython-%s.tar.gz' % (version, version),
+    'http://www.dnspython.org/kits/{}/dnspython-{}.tar.gz'.format(version, version),
     'classifiers' : [
         "Development Status :: 5 - Production/Stable",
         "Intended Audience :: Developers",
index a684ca1f2e7062ed6526edc03b60b78fe5211366..6c4d01642a1e7a1545390bc76e607afee652119c 100644 (file)
@@ -20,7 +20,7 @@ from dns.exception import DNSException
 
 class FormatedError(DNSException):
     fmt = "Custom format: {parameter}"
-    supp_kwargs = set(['parameter'])
+    supp_kwargs = {'parameter'}
 
 
 class ExceptionTestCase(unittest.TestCase):
index 4fea7afca5463b9100722221c344c2567be44d9e..48f8dd1bf6e520cd607e45215865842ec0a259f2 100644 (file)
@@ -29,27 +29,27 @@ class RdtypeAnyDnskeyTestCase(unittest.TestCase):
         good_f = 0
         from_flags = dns.rdtypes.ANY.DNSKEY.flags_to_text_set(good_f)
         self.failUnless(from_flags == good_s,
-                        '"%s" != "%s"' % (from_flags, good_s))
+                        '"{}" != "{}"'.format(from_flags, good_s))
         from_set = dns.rdtypes.ANY.DNSKEY.flags_from_text_set(good_s)
         self.failUnless(from_set == good_f,
-                        '"0x%x" != "0x%x"' % (from_set, good_f))
+                        '"0x{:x}" != "0x{:x}"'.format(from_set, good_f))
 
     def testFlagsAll(self): # type: () -> None
         '''Test that all defined flags are recognized.'''
-        good_s = set(['SEP', 'REVOKE', 'ZONE'])
+        good_s = {'SEP', 'REVOKE', 'ZONE'}
         good_f = 0x181
         from_flags = dns.rdtypes.ANY.DNSKEY.flags_to_text_set(good_f)
         self.failUnless(from_flags == good_s,
-                        '"%s" != "%s"' % (from_flags, good_s))
+                        '"{}" != "{}"'.format(from_flags, good_s))
         from_text = dns.rdtypes.ANY.DNSKEY.flags_from_text_set(good_s)
         self.failUnless(from_text == good_f,
-                        '"0x%x" != "0x%x"' % (from_text, good_f))
+                        '"0x{:x}" != "0x{:x}"'.format(from_text, good_f))
 
     def testFlagsUnknownToText(self): # type: () -> None
         '''Test that undefined flags are returned in hexadecimal notation.'''
-        unk_s = set(['0x8000'])
+        unk_s = {'0x8000'}
         flags_s = dns.rdtypes.ANY.DNSKEY.flags_to_text_set(0x8000)
-        self.failUnless(flags_s == unk_s, '"%s" != "%s"' % (flags_s, unk_s))
+        self.failUnless(flags_s == unk_s, '"{}" != "{}"'.format(flags_s, unk_s))
 
     def testFlagsUnknownToFlags(self): # type: () -> None
         '''Test that conversion from undefined mnemonic raises error.'''
@@ -60,9 +60,9 @@ class RdtypeAnyDnskeyTestCase(unittest.TestCase):
     def testFlagsRRToText(self): # type: () -> None
         '''Test that RR method returns correct flags.'''
         rr = dns.rrset.from_text('foo', 300, 'IN', 'DNSKEY', '257 3 8 KEY=')[0]
-        rr_s = set(['ZONE', 'SEP'])
+        rr_s = {'ZONE', 'SEP'}
         flags_s = rr.flags_to_text_set()
-        self.failUnless(flags_s == rr_s, '"%s" != "%s"' % (flags_s, rr_s))
+        self.failUnless(flags_s == rr_s, '"{}" != "{}"'.format(flags_s, rr_s))
 
 
 if __name__ == '__main__':
index e6936c3d734fc98454553bb91355e163aed59291..7f5990e3954415e18d13b1c20995b8b9022e1821 100644 (file)
@@ -28,7 +28,7 @@ class RdtypeAnyLocTestCase(unittest.TestCase):
         r2 = dns.rrset.from_text('FOO', 600, 'in', 'loc',
                                  '49 11 42.400 N 16 36 29.600 E 227.64m '
                                  '1.00m 10000.00m 10.00m')
-        self.failUnless(r1 == r2, '"%s" != "%s"' % (r1, r2))
+        self.failUnless(r1 == r2, '"{}" != "{}"'.format(r1, r2))
 
     def testEqual2(self):
         '''Test default values for size, horizontal and vertical precision.'''
@@ -39,7 +39,7 @@ class RdtypeAnyLocTestCase(unittest.TestCase):
                                      (16, 36, 29, 600, 1),
                                      22764.0, # centimeters
                                      100.0, 1000000.00, 1000.0)  # centimeters
-        self.failUnless(r1 == r2, '"%s" != "%s"' % (r1, r2))
+        self.failUnless(r1 == r2, '"{}" != "{}"'.format(r1, r2))
 
     def testEqual3(self):
         '''Test size, horizontal and vertical precision parsers: 100 cm == 1 m.
@@ -51,7 +51,7 @@ class RdtypeAnyLocTestCase(unittest.TestCase):
         r2 = dns.rrset.from_text('FOO', 600, 'in', 'loc',
                                  '49 11 42.400 N 16 36 29.600 E 227.64m '
                                  '2.00m 10.00m 2.00m')[0]
-        self.failUnless(r1 == r2, '"%s" != "%s"' % (r1, r2))
+        self.failUnless(r1 == r2, '"{}" != "{}"'.format(r1, r2))
 
     def testEqual4(self):
         '''Test size, horizontal and vertical precision parsers without unit.
@@ -64,7 +64,7 @@ class RdtypeAnyLocTestCase(unittest.TestCase):
         r2 = dns.rrset.from_text('FOO', 600, 'in', 'loc',
                                  '49 11 42.400 N 16 36 29.600 E 227.64 '
                                  '2 10 2')[0] # meters without explicit unit
-        self.failUnless(r1 == r2, '"%s" != "%s"' % (r1, r2))
+        self.failUnless(r1 == r2, '"{}" != "{}"'.format(r1, r2))
 
 if __name__ == '__main__':
     unittest.main()