diff --git a/logging/tests/unit/handlers/test__helpers.py b/logging/tests/unit/handlers/test__helpers.py index b5ba26fd17a75..7020159617713 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/google/cloud/pubsub_v1/gapic/publisher_client.py b/pubsub/google/cloud/pubsub_v1/gapic/publisher_client.py index 774fda25d6224..e02e2923933c2 100644 --- a/pubsub/google/cloud/pubsub_v1/gapic/publisher_client.py +++ b/pubsub/google/cloud/pubsub_v1/gapic/publisher_client.py @@ -51,10 +51,10 @@ # 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 f71230a89cea6..92f1a18d1c1df 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 f2609d63e4289..340c6acdd03a3 100644 --- a/storage/tests/unit/test__signing.py +++ b/storage/tests/unit/test__signing.py @@ -69,7 +69,7 @@ def test_w_expiration_int(self): self.assertEqual(self._call_fut(123), 123) def test_w_expiration_long(self): - if six.PY3: + if not six.PY2: raise unittest.SkipTest("No long on Python 3") self.assertEqual(self._call_fut(long(123)), 123) # noqa: F821