diff --git a/logging/tests/unit/handlers/test__helpers.py b/logging/tests/unit/handlers/test__helpers.py index b5ba26fd17a7..702015961771 100644 --- a/logging/tests/unit/handlers/test__helpers.py +++ b/logging/tests/unit/handlers/test__helpers.py @@ -77,7 +77,7 @@ def get(self): self.response.out.write(json.dumps(trace_id)) -@unittest.skipIf(six.PY3, "webapp2 is Python 2 only") +@unittest.skipIf(not six.PY2, "webapp2 is Python 2 only") class Test_get_trace_id_from_webapp2(unittest.TestCase): @staticmethod def create_app(): diff --git a/pubsub/synth.py b/pubsub/synth.py index a65bf2bf4f56..88ac4a8d4f7e 100644 --- a/pubsub/synth.py +++ b/pubsub/synth.py @@ -127,10 +127,10 @@ "google/cloud/pubsub_v1/gapic/publisher_client.py", "class PublisherClient", """# TODO: remove conditional import after Python 2 support is dropped -if six.PY3: - from collections.abc import Mapping -else: +if six.PY2: from collections import Mapping +else: + from collections.abc import Mapping def _merge_dict(d1, d2): diff --git a/storage/google/cloud/storage/batch.py b/storage/google/cloud/storage/batch.py index f71230a89cea..92f1a18d1c1d 100644 --- a/storage/google/cloud/storage/batch.py +++ b/storage/google/cloud/storage/batch.py @@ -214,10 +214,10 @@ def _prepare_batch_request(self): timeout = _timeout # The `email` package expects to deal with "native" strings - if six.PY3: # pragma: NO COVER Python3 - buf = io.StringIO() - else: + if six.PY2: # pragma: NO COVER Python3 buf = io.BytesIO() + else: + buf = io.StringIO() generator = Generator(buf, False, 0) generator.flatten(multi) payload = buf.getvalue() diff --git a/storage/tests/unit/test__signing.py b/storage/tests/unit/test__signing.py index f2609d63e428..bce709201dc4 100644 --- a/storage/tests/unit/test__signing.py +++ b/storage/tests/unit/test__signing.py @@ -69,8 +69,8 @@ def test_w_expiration_int(self): self.assertEqual(self._call_fut(123), 123) def test_w_expiration_long(self): - if six.PY3: - raise unittest.SkipTest("No long on Python 3") + if not six.PY2: + raise unittest.SkipTest("No long on Python 3+") self.assertEqual(self._call_fut(long(123)), 123) # noqa: F821