tests: Consolidate version (2 vs. 3) and platform (CPython vs. PyPy) checks (#2376)

Fix logic in test_bytes_to_string

Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
diff --git a/tests/test_buffers.py b/tests/test_buffers.py
index e264311..db1871e 100644
--- a/tests/test_buffers.py
+++ b/tests/test_buffers.py
@@ -1,15 +1,12 @@
 # -*- coding: utf-8 -*-
 import io
 import struct
-import sys
 
 import pytest
 
 from pybind11_tests import buffers as m
 from pybind11_tests import ConstructorStats
 
-PY3 = sys.version_info[0] >= 3
-
 pytestmark = pytest.requires_numpy
 
 with pytest.suppress(ImportError):
@@ -98,7 +95,7 @@
 def test_readonly_buffer():
     buf = m.BufferReadOnly(0x64)
     view = memoryview(buf)
-    assert view[0] == 0x64 if PY3 else b'd'
+    assert view[0] == b'd' if pytest.PY2 else 0x64
     assert view.readonly
 
 
@@ -106,7 +103,7 @@
 def test_selective_readonly_buffer():
     buf = m.BufferReadOnlySelect()
 
-    memoryview(buf)[0] = 0x64 if PY3 else b'd'
+    memoryview(buf)[0] = b'd' if pytest.PY2 else 0x64
     assert buf.value == 0x64
 
     io.BytesIO(b'A').readinto(buf)
@@ -114,6 +111,6 @@
 
     buf.readonly = True
     with pytest.raises(TypeError):
-        memoryview(buf)[0] = 0 if PY3 else b'\0'
+        memoryview(buf)[0] = b'\0' if pytest.PY2 else 0
     with pytest.raises(TypeError):
         io.BytesIO(b'1').readinto(buf)