Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[tool.briefcase]
version = "1.2.3"
description = "A sample app"
bundle = "org.beeware"
mystery = 'default'
[tool.briefcase.app.firstapp]
sources = ['src/firstapp']
""")
# Parse the configuration.
# Even though the global config has everything needed for the default
# configuration, it's missing a required option for the custom class.
with pytest.raises(
BriefcaseConfigError,
match=r"Global configuration is incomplete \(missing 'foo'\)"
):
other_command.parse_config(filename)
def test_missing_config(base_command):
"If the configuration file doesn't exit, raise an error"
filename = str(base_command.base_path / 'does_not_exist.toml')
with pytest.raises(BriefcaseConfigError, match="configuration file not found"):
base_command.parse_config(filename)
def test_invalid_toml():
"If the config file isn't TOML, raise an error"
config_file = StringIO("this is not toml!")
with pytest.raises(BriefcaseConfigError, match="Invalid pyproject.toml"):
parse_config(config_file, platform='macos', output_format='app')
def test_no_briefcase_section():
"If the config file doesn't contain a briefcase tool section, raise an error"
config_file = StringIO(
"""
[build-system]
requires = ["briefcase"]
[tool.section]
name="value"
number=42
"""
)
with pytest.raises(BriefcaseConfigError, match="No tool.briefcase section"):
parse_config(config_file, platform='macos', output_format='app')
def test_valid_app_name(name):
try:
AppConfig(
name=name,
version="1.2.3",
bundle="org.beeware",
description="A simple app",
sources=['src/' + name.replace('-', '_')]
)
except BriefcaseConfigError:
pytest.fail('{name} should be valid'.format(name=name))
def test_no_source_for_app():
with pytest.raises(BriefcaseConfigError, match=r" does not include a package named 'my_app'\."):
AppConfig(
name='my-app',
version="1.2.3",
bundle="org.beeware",
description="A simple app",
sources=['src/something', 'src/other']
)
except TypeError:
# Inspect the GlobalConfig constructor to find which
# parameters are required and don't have a default
# value.
required_args = {
name
for name, param in inspect.signature(klass.__init__).parameters.items()
if param.default == inspect._empty
and name not in {'self', 'kwargs'}
}
missing_args = required_args - config.keys()
missing = ', '.join(
"'{arg}'".format(arg=arg)
for arg in sorted(missing_args)
)
raise BriefcaseConfigError(
"{msg} is incomplete (missing {missing})".format(
msg=msg,
missing=missing
)
msg="Global configuration"
)
for app_name, app_config in app_configs.items():
# Construct an AppConfig object with the final set of
# configuration options for the app.
self.apps[app_name] = create_config(
klass=self.APP_CONFIG_CLASS,
config=app_config,
msg="Configuration for '{app_name}'".format(
app_name=app_name
)
)
except FileNotFoundError:
raise BriefcaseConfigError('configuration file not found')