Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_installed_with_minimum_version_success(min_version, version, capsys):
"Check XCode can meet a minimum version requirement."
sub = mock.MagicMock()
sub.check_output.return_value = "Xcode {version}\nBuild version 11B500\n".format(
version=version
)
# Check passes without an error.
ensure_xcode_is_installed(min_version=min_version, sub=sub)
# Make sure the warning wasn't displayed.
out = capsys.readouterr().out
assert "WARNING" not in out
def test_installed_no_minimum_version():
"If Xcode is installed, but there's no minimum version, check is satisfied."
sub = mock.MagicMock()
sub.check_output.return_value = "Xcode 11.2.1\nBuild version 11B500\n"
# Check passes without an error.
ensure_xcode_is_installed(sub=sub)
def test_installed_with_minimum_version_failure(min_version, version):
"Check XCode fail to meet a minimum version requirement."
sub = mock.MagicMock()
sub.check_output.return_value = "Xcode {version}\nBuild version 11B500\n".format(
version=version
)
# Check raises an error.
with pytest.raises(BriefcaseCommandError):
ensure_xcode_is_installed(min_version=min_version, sub=sub)
def test_not_installed():
"If Xcode is not installed, raise an error."
sub = mock.MagicMock()
sub.check_output.side_effect = subprocess.CalledProcessError(
cmd=['xcodebuild', '-version'],
returncode=1
)
with pytest.raises(BriefcaseCommandError):
ensure_xcode_is_installed(sub=sub)
def test_unexpected_version_output(capsys):
"If xcodebuild returns unexpected output, assume it's ok..."
sub = mock.MagicMock()
sub.check_output.return_value = "Wibble Wibble Wibble\n"
# Check passes without an error...
ensure_xcode_is_installed(min_version=(11, 2, 1), sub=sub)
# ...but stdout contains a warning
out = capsys.readouterr().out
assert '************' in out
def verify_tools(self):
if self.host_os != 'Darwin':
raise BriefcaseCommandError("""
iOS applications require Xcode, which is only available on macOS.
""")
# Require XCode 10.0.0. There's no particular reason for this
# specific version, other than it's a nice round number that's
# not *that* old at time of writing.
ensure_xcode_is_installed(min_version=(10, 0, 0))