diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfigurationLoader.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfigurationLoader.java index a898e2cb426..6e73aa5bc9c 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfigurationLoader.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfigurationLoader.java @@ -36,16 +36,11 @@ public PythonConfiguration create(BuildOptions buildOptions) PythonVersion pythonVersion = pythonOptions.getPythonVersion(); return new PythonConfiguration( pythonVersion, - pythonOptions.getDefaultPythonVersion(), pythonOptions.buildPythonZip, pythonOptions.buildTransitiveRunfilesTrees, - /*oldPyVersionApiAllowed=*/ !pythonOptions.incompatibleRemoveOldPythonVersionApi, - /*useNewPyVersionSemantics=*/ pythonOptions.incompatibleAllowPythonVersionTransitions, - /*py2OutputsAreSuffixed=*/ pythonOptions.incompatiblePy2OutputsAreSuffixed, - /*disallowLegacyPyProvider=*/ pythonOptions.incompatibleDisallowLegacyPyProvider, - /*useToolchains=*/ pythonOptions.incompatibleUsePythonToolchains, - /*loadPythonRulesFromBzl=*/ pythonOptions.loadPythonRulesFromBzl, - /*defaultToExplicitInitPy=*/ pythonOptions.incompatibleDefaultToExplicitInitPy); + /*oldPyVersionApiAllowed=*/ !pythonOptions.experimentalRemoveOldPythonVersionApi, + /*useNewPyVersionSemantics=*/ pythonOptions.experimentalAllowPythonVersionTransitions, + /*disallowLegacyPyProvider=*/ pythonOptions.incompatibleDisallowLegacyPyProvider); } @Override diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java index 09814484f68..1c8a9e40c39 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java @@ -69,28 +69,30 @@ public String getTypeDescription() { help = "Build python executable zip; on on Windows, off on other platforms") public TriState buildPythonZip; + // TODO(brandjon): For both experimental options below, add documentation and add a link to it + // from the help text, then change the documentationCategory to SKYLARK_SEMANTICS. + @Option( name = "experimental_remove_old_python_version_api", + // TODO(brandjon): Do not flip until we have an answer for how to disallow the + // "default_python_version" attribute without hacking up native.existing_rules(). See + // #7071 and b/122596733. defaultValue = "false", - documentationCategory = OptionDocumentationCategory.SKYLARK_SEMANTICS, + documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS}, metadataTags = {OptionMetadataTag.EXPERIMENTAL}, help = "If true, disables use of the `--force_python` flag and the `default_python_version` " - + "attribute for `py_binary` and `py_test`. Use the `--python_version` flag and " - + "`python_version` attribute instead, which have exactly the same meaning. This " - + "flag also disables `select()`-ing over `--host_force_python`.") + + "attribute for `py_binary` and `py_test`.") public boolean experimentalRemoveOldPythonVersionApi; @Option( name = "experimental_allow_python_version_transitions", defaultValue = "false", - documentationCategory = OptionDocumentationCategory.SKYLARK_SEMANTICS, + documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS}, metadataTags = {OptionMetadataTag.EXPERIMENTAL}, - help = - "If true, Python rules use the new PY2/PY3 version semantics. For more information, see " - + "the documentation for `py_binary`'s `python_version` attribute.") + help = "If true, Python rules use the new PY2/PY3 version semantics.") public boolean experimentalAllowPythonVersionTransitions; /** @@ -105,16 +107,17 @@ public String getTypeDescription() { name = "python_version", defaultValue = "null", converter = TargetPythonVersionConverter.class, - documentationCategory = OptionDocumentationCategory.GENERIC_INPUTS, + // TODO(brandjon): Change to OptionDocumentationCategory.GENERIC_INPUTS when this is + // sufficiently implemented/documented. + documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, effectTags = { OptionEffectTag.LOADING_AND_ANALYSIS, OptionEffectTag.AFFECTS_OUTPUTS // because of "-py3" output root }, help = - "The Python major version mode, either `PY2` or `PY3`. Note that under the new version " - + "semantics (`--experimental_allow_python_version_transitions`) this is overridden " - + "by `py_binary` and `py_test` targets (even if they don't explicitly specify a " - + "version) so there is usually not much reason to supply this flag.") + "The Python major version mode, either `PY2` or `PY3`. Note that this is overridden by " + + "`py_binary` and `py_test` targets (whether or not they specify their version " + + "explicitly), so there is usually not much reason to supply this flag.") public PythonVersion pythonVersion; private static final OptionDefinition PYTHON_VERSION_DEFINITION = @@ -137,9 +140,7 @@ public String getTypeDescription() { converter = TargetPythonVersionConverter.class, documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS, effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS, OptionEffectTag.AFFECTS_OUTPUTS}, - help = - "Deprecated alias for `--python_version`. Disabled by " - + "`--experimental_remove_old_python_version_api`.") + help = "Overrides default_python_version attribute. Can be \"PY2\" or \"PY3\".") public PythonVersion forcePython; private static final OptionDefinition FORCE_PYTHON_DEFINITION = @@ -185,25 +186,19 @@ public String getTypeDescription() { @Override public Map getSelectRestrictions() { - // TODO(brandjon): Instead of referencing the python_version target, whose path depends on the - // tools repo name, reference a standalone documentation page instead. + // TODO(brandjon): Add an error string that references documentation explaining to use + // @bazel_tools//tools/python:python_version instead. ImmutableMap.Builder restrictions = ImmutableMap.builder(); restrictions.put( PYTHON_VERSION_DEFINITION, - new SelectRestriction( - /*visibleWithinToolsPackage=*/ true, - "Use @bazel_tools//python/tools:python_version instead.")); + new SelectRestriction(/*visibleWithinToolsPackage=*/ true, /*errorMessage=*/ null)); if (experimentalRemoveOldPythonVersionApi) { restrictions.put( FORCE_PYTHON_DEFINITION, - new SelectRestriction( - /*visibleWithinToolsPackage=*/ true, - "Use @bazel_tools//python/tools:python_version instead.")); + new SelectRestriction(/*visibleWithinToolsPackage=*/ true, /*errorMessage=*/ null)); restrictions.put( HOST_FORCE_PYTHON_DEFINITION, - new SelectRestriction( - /*visibleWithinToolsPackage=*/ false, - "Use @bazel_tools//python/tools:python_version instead.")); + new SelectRestriction(/*visibleWithinToolsPackage=*/ false, /*errorMessage=*/ null)); } return restrictions.build(); } diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/python/PyBaseConfiguredTargetTestBase.java b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/python/PyBaseConfiguredTargetTestBase.java index d3767f6cba1..ac331bc0373 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/python/PyBaseConfiguredTargetTestBase.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/python/PyBaseConfiguredTargetTestBase.java @@ -15,11 +15,10 @@ package com.google.devtools.build.lib.rules.python; import static com.google.common.truth.Truth.assertThat; -import static com.google.devtools.build.lib.rules.python.PythonTestUtils.assumesDefaultIsPY2; +import static com.google.devtools.build.lib.rules.python.PythonTestUtils.ensureDefaultIsPY2; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; -import com.google.devtools.build.lib.packages.util.MockPythonSupport; import org.junit.Before; import org.junit.Test; @@ -69,7 +68,7 @@ public void goodSrcsVersionValue() throws Exception { } @Test - public void srcsVersionClashesWithVersionFlagUnderOldSemantics() throws Exception { + public void srcsVersionClashesWithForcePythonFlagUnderOldSemantics() throws Exception { // Under the old version semantics, we fail on any Python target the moment a conflict between // srcs_version and the configuration is detected. Under the new semantics, py_binary and // py_test care if there's a conflict but py_library does not. This test case checks the old @@ -77,8 +76,7 @@ public void srcsVersionClashesWithVersionFlagUnderOldSemantics() throws Exceptio // PyExecutableConfiguredTargetTestBase. Note that under the new semantics py_binary and // py_library ignore the version flag, so those tests use the attribute to set the version // instead. - useConfiguration( - "--incompatible_allow_python_version_transitions=false", "--python_version=PY3"); + useConfiguration("--experimental_allow_python_version_transitions=false", "--force_python=PY3"); checkError("pkg", "foo", // error: "'//pkg:foo' can only be used with Python 2", @@ -91,7 +89,7 @@ public void srcsVersionClashesWithVersionFlagUnderOldSemantics() throws Exceptio @Test public void versionIs2IfUnspecified() throws Exception { - assumesDefaultIsPY2(); + ensureDefaultIsPY2(); scratch.file( "pkg/BUILD", // ruleName + "(", @@ -102,14 +100,13 @@ public void versionIs2IfUnspecified() throws Exception { @Test public void versionIs3IfForcedByFlagUnderOldSemantics() throws Exception { - // Under the old version semantics, --python_version takes precedence over the rule's own + // Under the old version semantics, --force_python takes precedence over the rule's own // default_python_version attribute, so this test case applies equally well to py_library, // py_binary, and py_test. Under the new semantics the rule attribute takes precedence, so this // would only make sense for py_library; see PyLibraryConfiguredTargetTest for the analogous // test. - assumesDefaultIsPY2(); - useConfiguration( - "--incompatible_allow_python_version_transitions=false", "--python_version=PY3"); + ensureDefaultIsPY2(); + useConfiguration("--experimental_allow_python_version_transitions=false", "--force_python=PY3"); scratch.file( "pkg/BUILD", // ruleName + "(", @@ -272,46 +269,4 @@ public void requiresProvider() throws Exception { " deps = [':dep'],", ")"); } - - @Test - public void loadFromBzl_WithMagicTagPasses() throws Exception { - useConfiguration("--incompatible_load_python_rules_from_bzl=true"); - scratch.file( - "pkg/BUILD", - MockPythonSupport.getMacroLoadStatementFor(ruleName), - ruleName + "(", - " name = 'foo',", - " srcs = ['foo.py'],", - ")"); - assertThat(getConfiguredTarget("//pkg:foo")).isNotNull(); - assertNoEvents(); - } - - @Test - public void loadFromBzl_WithoutMagicTagFails() throws Exception { - useConfiguration("--incompatible_load_python_rules_from_bzl=true"); - checkError( - "pkg", - "foo", - // error: - "Direct access to the native Python rules is deprecated", - // build file: - ruleName + "(", - " name = 'foo',", - " srcs = ['foo.py'],", - ")"); - } - - @Test - public void loadFromBzl_WithoutFlagPasses() throws Exception { - useConfiguration("--incompatible_load_python_rules_from_bzl=false"); - scratch.file( - "pkg/BUILD", // - ruleName + "(", - " name = 'foo',", - " srcs = ['foo.py'],", - ")"); - assertThat(getConfiguredTarget("//pkg:foo")).isNotNull(); - assertNoEvents(); - } } diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/python/PythonConfigurationTest.java b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/python/PythonConfigurationTest.java index ecb94703bb9..204383a3ace 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/python/PythonConfigurationTest.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/python/PythonConfigurationTest.java @@ -52,64 +52,26 @@ public void invalidTargetPythonValue_UnknownValue() { } @Test - public void oldVersionFlagGatedByIncompatibleFlag() throws Exception { - create("--incompatible_remove_old_python_version_api=false", "--force_python=PY2"); + public void oldVersionFlagGatedByExperimentalFlag() throws Exception { + create("--experimental_remove_old_python_version_api=false", "--force_python=PY2"); checkError( - "`--force_python` is disabled by `--incompatible_remove_old_python_version_api`", - "--incompatible_remove_old_python_version_api=true", + "`--force_python` is disabled by `--experimental_remove_old_python_version_api`", + "--experimental_remove_old_python_version_api=true", "--force_python=PY2"); } @Test - public void py3IsDefaultFlagRequiresNewSemanticsFlag() throws Exception { - checkError( - "cannot enable `--incompatible_py3_is_default` without also enabling " - + "`--incompatible_allow_python_version_transitions`", - "--incompatible_allow_python_version_transitions=false", - "--incompatible_py3_is_default=true"); - } - - @Test - public void getDefaultPythonVersion() throws Exception { - // --incompatible_py3_is_default requires --incompatible_allow_python_version_transitions - PythonOptions withoutPy3IsDefaultOpts = - parsePythonOptions( - "--incompatible_allow_python_version_transitions=true", - "--incompatible_py3_is_default=false"); - PythonOptions withPy3IsDefaultOpts = - parsePythonOptions( - "--incompatible_allow_python_version_transitions=true", - "--incompatible_py3_is_default=true"); - assertThat(withoutPy3IsDefaultOpts.getDefaultPythonVersion()).isEqualTo(PythonVersion.PY2); - assertThat(withPy3IsDefaultOpts.getDefaultPythonVersion()).isEqualTo(PythonVersion.PY3); - } - - @Test - public void getPythonVersion_FallBackOnDefaultPythonVersion() throws Exception { - // Run it twice with two different values for the incompatible flag to confirm it's actually - // reading getDefaultPythonVersion() and not some other source of default values. Note that - // --incompatible_py3_is_default requires --incompatible_allow_python_version_transitions. - PythonOptions py2Opts = - parsePythonOptions( - "--incompatible_allow_python_version_transitions=true", - "--incompatible_py3_is_default=false"); - PythonOptions py3Opts = - parsePythonOptions( - "--incompatible_allow_python_version_transitions=true", - "--incompatible_py3_is_default=true"); - assertThat(py2Opts.getPythonVersion()).isEqualTo(PythonVersion.PY2); - assertThat(py3Opts.getPythonVersion()).isEqualTo(PythonVersion.PY3); + public void getPythonVersion_HardcodedDefaultWhenOmitted() throws Exception { + ensureDefaultIsPY2(); + PythonOptions opts = parsePythonOptions(); + assertThat(opts.getPythonVersion()).isEqualTo(PythonVersion.PY2); } @Test public void getPythonVersion_NewFlagTakesPrecedence() throws Exception { ensureDefaultIsPY2(); // --force_python is superseded by --python_version. - PythonOptions opts = - parsePythonOptions( - "--incompatible_remove_old_python_version_api=false", - "--force_python=PY2", - "--python_version=PY3"); + PythonOptions opts = parsePythonOptions("--force_python=PY2", "--python_version=PY3"); assertThat(opts.getPythonVersion()).isEqualTo(PythonVersion.PY3); } @@ -117,9 +79,7 @@ public void getPythonVersion_NewFlagTakesPrecedence() throws Exception { public void getPythonVersion_FallBackOnOldFlag() throws Exception { ensureDefaultIsPY2(); // --force_python is used because --python_version is absent. - PythonOptions opts = - parsePythonOptions( - "--incompatible_remove_old_python_version_api=false", "--force_python=PY3"); + PythonOptions opts = parsePythonOptions("--force_python=PY3"); assertThat(opts.getPythonVersion()).isEqualTo(PythonVersion.PY3); } @@ -127,7 +87,7 @@ public void getPythonVersion_FallBackOnOldFlag() throws Exception { public void canTransitionPythonVersion_OldSemantics_Yes() throws Exception { ensureDefaultIsPY2(); PythonOptions opts = - parsePythonOptions("--incompatible_allow_python_version_transitions=false"); + parsePythonOptions("--experimental_allow_python_version_transitions=false"); assertThat(opts.canTransitionPythonVersion(PythonVersion.PY3)).isTrue(); } @@ -136,12 +96,12 @@ public void canTransitionPythonVersion_OldSemantics_NoBecauseAlreadySet() throws ensureDefaultIsPY2(); PythonOptions optsWithOldFlag = parsePythonOptions( - "--incompatible_allow_python_version_transitions=false", - "--incompatible_remove_old_python_version_api=false", + "--experimental_allow_python_version_transitions=false", + "--experimental_remove_old_python_version_api=false", "--force_python=PY2"); PythonOptions optsWithNewFlag = parsePythonOptions( - "--incompatible_allow_python_version_transitions=false", "--python_version=PY2"); + "--experimental_allow_python_version_transitions=false", "--python_version=PY2"); assertThat(optsWithOldFlag.canTransitionPythonVersion(PythonVersion.PY3)).isFalse(); assertThat(optsWithNewFlag.canTransitionPythonVersion(PythonVersion.PY3)).isFalse(); } @@ -151,7 +111,7 @@ public void canTransitionPythonVersion_OldSemantics_NoBecauseNewValueSameAsDefau throws Exception { ensureDefaultIsPY2(); PythonOptions opts = - parsePythonOptions("--incompatible_allow_python_version_transitions=false"); + parsePythonOptions("--experimental_allow_python_version_transitions=false"); assertThat(opts.canTransitionPythonVersion(PythonVersion.PY2)).isFalse(); } @@ -159,7 +119,7 @@ public void canTransitionPythonVersion_OldSemantics_NoBecauseNewValueSameAsDefau public void canTransitionPythonVersion_NewSemantics_Yes() throws Exception { PythonOptions opts = parsePythonOptions( - "--incompatible_allow_python_version_transitions=true", "--python_version=PY3"); + "--experimental_allow_python_version_transitions=true", "--python_version=PY3"); assertThat(opts.canTransitionPythonVersion(PythonVersion.PY2)).isTrue(); } @@ -167,35 +127,32 @@ public void canTransitionPythonVersion_NewSemantics_Yes() throws Exception { public void canTransitionPythonVersion_NewSemantics_NoBecauseSameAsCurrent() throws Exception { PythonOptions opts = parsePythonOptions( - "--incompatible_allow_python_version_transitions=true", + "--experimental_allow_python_version_transitions=true", // Set --force_python too, or else we fall into the "make --force_python consistent" // case. - "--incompatible_remove_old_python_version_api=false", + "--experimental_remove_old_python_version_api=false", "--force_python=PY3", "--python_version=PY3"); assertThat(opts.canTransitionPythonVersion(PythonVersion.PY3)).isFalse(); } @Test - public void canTransitionPythonVersion_NewApi_NoEvenWhenForcePythonDisagrees() throws Exception { + public void canTransitionPythonVersion_NewApi_YesBecauseForcePythonDisagrees() throws Exception { PythonOptions opts = parsePythonOptions( - "--incompatible_allow_python_version_transitions=true", - "--incompatible_remove_old_python_version_api=false", - // Test that even though --force_python's value isn't in sync, we don't transition - // because getPythonVersion() would be unaffected by the transition. + "--experimental_allow_python_version_transitions=true", + "--experimental_remove_old_python_version_api=false", + // Test that even though getPythonVersion() would not be affected by a transition (it is + // PY3 before and after), the transition is still considered necessary because + // --force_python's value needs to be brought in sync. "--force_python=PY2", "--python_version=PY3"); - assertThat(opts.canTransitionPythonVersion(PythonVersion.PY3)).isFalse(); + assertThat(opts.canTransitionPythonVersion(PythonVersion.PY3)).isTrue(); } @Test public void setPythonVersion() throws Exception { - PythonOptions opts = - parsePythonOptions( - "--incompatible_remove_old_python_version_api=false", - "--force_python=PY2", - "--python_version=PY2"); + PythonOptions opts = parsePythonOptions("--force_python=PY2", "--python_version=PY2"); opts.setPythonVersion(PythonVersion.PY3); assertThat(opts.forcePython).isEqualTo(PythonVersion.PY3); assertThat(opts.pythonVersion).isEqualTo(PythonVersion.PY3); @@ -205,59 +162,30 @@ public void setPythonVersion() throws Exception { public void getHost_CopiesMostValues() throws Exception { PythonOptions opts = parsePythonOptions( - "--incompatible_allow_python_version_transitions=true", - "--incompatible_remove_old_python_version_api=true", - "--incompatible_py3_is_default=true", - "--incompatible_py2_outputs_are_suffixed=true", + "--experimental_allow_python_version_transitions=true", + "--experimental_remove_old_python_version_api=true", "--build_python_zip=true", - "--incompatible_disallow_legacy_py_provider=true", - "--experimental_use_python_toolchains=true"); + "--incompatible_disallow_legacy_py_provider=true"); PythonOptions hostOpts = (PythonOptions) opts.getHost(); - assertThat(hostOpts.incompatibleAllowPythonVersionTransitions).isTrue(); - assertThat(hostOpts.incompatibleRemoveOldPythonVersionApi).isTrue(); - assertThat(hostOpts.incompatiblePy3IsDefault).isTrue(); - assertThat(hostOpts.incompatiblePy2OutputsAreSuffixed).isTrue(); + assertThat(hostOpts.experimentalAllowPythonVersionTransitions).isTrue(); + assertThat(hostOpts.experimentalRemoveOldPythonVersionApi).isTrue(); assertThat(hostOpts.buildPythonZip).isEqualTo(TriState.YES); assertThat(hostOpts.incompatibleDisallowLegacyPyProvider).isTrue(); - assertThat(hostOpts.incompatibleUsePythonToolchains).isTrue(); } @Test public void getHost_AppliesHostForcePython() throws Exception { ensureDefaultIsPY2(); - PythonOptions optsWithForcePythonFlag = + PythonOptions optsWithOldFlag = parsePythonOptions( - "--incompatible_remove_old_python_version_api=false", + "--experimental_remove_old_python_version_api=false", "--force_python=PY2", "--host_force_python=PY3"); - PythonOptions optsWithPythonVersionFlag = + PythonOptions optsWithNewFlag = parsePythonOptions("--python_version=PY2", "--host_force_python=PY3"); - PythonOptions optsWithPy3IsDefaultFlag = - // --incompatible_py3_is_default requires --incompatible_allow_python_version_transitions - parsePythonOptions( - "--incompatible_allow_python_version_transitions=true", - "--incompatible_py3_is_default=true", - // It's more interesting to set the incompatible flag true and force host to PY2, than - // it is to set the flag false and force host to PY3. - "--host_force_python=PY2"); - PythonOptions hostOptsWithForcePythonFlag = (PythonOptions) optsWithForcePythonFlag.getHost(); - PythonOptions hostOptsWithPythonVersionFlag = - (PythonOptions) optsWithPythonVersionFlag.getHost(); - PythonOptions hostOptsWithPy3IsDefaultFlag = (PythonOptions) optsWithPy3IsDefaultFlag.getHost(); - assertThat(hostOptsWithForcePythonFlag.getPythonVersion()).isEqualTo(PythonVersion.PY3); - assertThat(hostOptsWithPythonVersionFlag.getPythonVersion()).isEqualTo(PythonVersion.PY3); - assertThat(hostOptsWithPy3IsDefaultFlag.getPythonVersion()).isEqualTo(PythonVersion.PY2); - } - - @Test - public void getHost_Py3IsDefaultFlagChangesHost() throws Exception { - ensureDefaultIsPY2(); - PythonOptions opts = - // --incompatible_py3_is_default requires --incompatible_allow_python_version_transitions - parsePythonOptions( - "--incompatible_allow_python_version_transitions=true", - "--incompatible_py3_is_default=true"); - PythonOptions hostOpts = (PythonOptions) opts.getHost(); - assertThat(hostOpts.getPythonVersion()).isEqualTo(PythonVersion.PY3); + PythonOptions hostOptsWithOldFlag = (PythonOptions) optsWithOldFlag.getHost(); + PythonOptions hostOptsWithNewFlag = (PythonOptions) optsWithNewFlag.getHost(); + assertThat(hostOptsWithOldFlag.getPythonVersion()).isEqualTo(PythonVersion.PY3); + assertThat(hostOptsWithNewFlag.getPythonVersion()).isEqualTo(PythonVersion.PY3); } }