URL: http://github.com/commitizen-tools/commitizen/pull/1925.diff
s(self): + return_code = cmd.run_interactive( + [ + "python", + "-c", + "import os, sys; sys.exit(0 if os.environ['CZ_ITEST_VAR'] == 'val' else 1)", + ], + env={"CZ_ITEST_VAR": "val"}, + ) + assert return_code == 0 + + def test_env_merged_with_os_environ(self, monkeypatch): + monkeypatch.setenv("CZ_ITEST_EXISTING", "yes") + return_code = cmd.run_interactive( + [ + "python", + "-c", + "import os, sys; sys.exit(0 if os.environ['CZ_ITEST_EXISTING'] == 'yes' else 1)", + ], + env={"CZ_ITEST_EXTRA": "extra"}, + ) + assert return_code == 0 + + def test_runs_with_string(self): + """Test that passing a string to cmd.run_interactive emits a DeprecationWarning.""" + import warnings + + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + return_code = cmd.run_interactive("python -c \"print('hello')\"") + assert return_code == 0 + assert len(w) == 1 + assert issubclass(w[0].category, DeprecationWarning) + assert "cmd.run_interactive()" in str(w[0].message) + + +class TestRunInteractiveShell: + def test_zero_return_code_on_success(self): + return_code = cmd.run_interactive_shell('python -c "import sys; sys.exit(0)"') + assert return_code == 0 + + def test_nonzero_return_code_on_failure(self): + return_code = cmd.run_interactive_shell('python -c "import sys; sys.exit(3)"') + assert return_code == 3 + + def test_env_passed_to_subprocess(self): + return_code = cmd.run_interactive_shell( + "python -c \"import os, sys; sys.exit(0 if os.environ['CZ_ITEST_VAR'] == 'val' else 1)\"", + env={"CZ_ITEST_VAR": "val"}, + ) + assert return_code == 0 + + def test_env_merged_with_os_environ(self, monkeypatch): + monkeypatch.setenv("CZ_ITEST_EXISTING", "yes") + return_code = cmd.run_interactive_shell( + "python -c \"import os, sys; sys.exit(0 if os.environ['CZ_ITEST_EXISTING'] == 'yes' else 1)\"", + env={"CZ_ITEST_EXTRA": "extra"}, + ) + assert return_code == 0Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: