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_run_full_directory(capsys, packages):
assert packages.is_dir()
file_list = []
for item in packages.iterdir():
if item.is_file():
file_list.append(item)
number_of_pkgs = len(file_list)
additional_options = {
'rpmfile': [packages],
}
options = {**options_preset, **additional_options}
linter = Lint(options)
linter.run()
out, err = capsys.readouterr()
assert f'0 packages and {number_of_pkgs} specfiles checked' in out
assert not err
def test_run_empty(capsys):
linter = Lint(options_preset)
linter.run()
out, err = capsys.readouterr()
assert err
assert '0 packages and 0 specfiles checked; 0 errors, 0 warnings' in out
def test_run_rpmlintrc_single_file(capsys, packages):
additional_options = {
'rpmfile': [packages],
}
options = {**options_preset, **additional_options}
linter = Lint(options)
linter.run()
out, err = capsys.readouterr()
assert not err
assert 'rpmlintrc:' in out
def test_run_installed_and_no_files(capsys):
additional_options = {
'rpmfile': [],
'installed': ['python3-rpm'],
}
options = {**options_preset, **additional_options}
linter = Lint(options)
linter.checks = _remove_except_zip(linter.checks)
linter.run()
out, err = capsys.readouterr()
assert '1 packages and 0 specfiles checked' in out
assert not err
def test_configoutput(capsys):
additional_options = {
'print_config': True,
}
options = {**options_preset, **additional_options}
linter = Lint(options)
linter.run()
out, err = capsys.readouterr()
assert out
assert 'Vendor = "Fedora Project"' in out
assert not err
def test_run_installed_not_present(capsys):
additional_options = {
'rpmfile': [],
'installed': ['non-existing-package'],
}
options = {**options_preset, **additional_options}
linter = Lint(options)
linter.checks = _remove_except_zip(linter.checks)
linter.run()
out, err = capsys.readouterr()
assert '0 packages and 0 specfiles checked' in out
assert 'there is no installed rpm' in err
assert 'There are no files to process' in err
def test_header_information(capsys):
additional_options = {
'rpmfile': [],
'installed': ['python3-rpm'],
}
options = {**options_preset, **additional_options}
linter = Lint(options)
linter.checks = _remove_except_zip(linter.checks)
linter.run()
out, err = capsys.readouterr()
assert 'packages: 1' in out
def test_cases_loading():
linter = Lint(options_preset)
assert list(linter.checks.keys()) == basic_tests
def test_run_rpmlintrc_single_dir(capsys, packages):
additional_options = {
'rpmfile': [packages],
}
options = {**options_preset, **additional_options}
linter = Lint(options)
linter.run()
out, err = capsys.readouterr()
assert not err
assert 'rpmlintrc:' in out
def lint():
"""
Main wrapper for lint command processing
"""
options = process_lint_args(sys.argv[1:])
lint = Lint(options)
sys.exit(lint.run())