fix(coverage): add test attributes in transition module (#1649)

This PR is to fix an issue that coverage report is empty when using
transition module.
This is due to the absence of the `_lcov_merger` and
`_collect_cc_coverage` attributes.
Coverage reports will be created adding these attributes.

Fixes https://github.com/bazelbuild/rules_python/issues/1600
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 31e8d25..c9baef7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -55,6 +55,9 @@
   instead with a location to the patch that could be used to silence the warning.
   Copy the patch to your workspace and add it to the list if patches for the wheel
   file if you decide to do so.
+* (coverage): coverage reports are now created when the version-aware
+  rules are used.
+  ([#1600](https://github.com/bazelbuild/rules_python/issues/1600))
 
 ### Added
 
diff --git a/python/config_settings/transition.bzl b/python/config_settings/transition.bzl
index 1b1a5e8..cd54b21 100644
--- a/python/config_settings/transition.bzl
+++ b/python/config_settings/transition.bzl
@@ -142,16 +142,33 @@
     ),
 }
 
+_PY_TEST_ATTRS = {
+    # Magic attribute to help C++ coverage work. There's no
+    # docs about this; see TestActionBuilder.java
+    "_collect_cc_coverage": attr.label(
+        default = "@bazel_tools//tools/test:collect_cc_coverage",
+        executable = True,
+        cfg = "exec",
+    ),
+    # Magic attribute to make coverage work. There's no
+    # docs about this; see TestActionBuilder.java
+    "_lcov_merger": attr.label(
+        default = configuration_field(fragment = "coverage", name = "output_generator"),
+        executable = True,
+        cfg = "exec",
+    ),
+}
+
 _transition_py_binary = rule(
     _transition_py_impl,
-    attrs = _COMMON_ATTRS,
+    attrs = _COMMON_ATTRS | _PY_TEST_ATTRS,
     cfg = _transition_python_version,
     executable = True,
 )
 
 _transition_py_test = rule(
     _transition_py_impl,
-    attrs = _COMMON_ATTRS,
+    attrs = _COMMON_ATTRS | _PY_TEST_ATTRS,
     cfg = _transition_python_version,
     test = True,
 )
diff --git a/python/private/common/py_binary_rule_bazel.bzl b/python/private/common/py_binary_rule_bazel.bzl
index 0266381..9ce0726 100644
--- a/python/private/common/py_binary_rule_bazel.bzl
+++ b/python/private/common/py_binary_rule_bazel.bzl
@@ -22,11 +22,15 @@
 )
 
 _PY_TEST_ATTRS = {
+    # Magic attribute to help C++ coverage work. There's no
+    # docs about this; see TestActionBuilder.java
     "_collect_cc_coverage": attr.label(
         default = "@bazel_tools//tools/test:collect_cc_coverage",
         executable = True,
         cfg = "exec",
     ),
+    # Magic attribute to make coverage work. There's no
+    # docs about this; see TestActionBuilder.java
     "_lcov_merger": attr.label(
         default = configuration_field(fragment = "coverage", name = "output_generator"),
         executable = True,