dnf/0001-Solve-problems-with-l-and-s-options-in-repoquery.patch
Igor Gnatenko a4f1343b4e Fix crash in repoquery; Trim changelog
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-10-06 10:23:48 +02:00

83 lines
3.0 KiB
Diff

From 060fc85260b66a7b6a4ac994801f4c544837a9e5 Mon Sep 17 00:00:00 2001
From: Jaroslav Mracek <jmracek@redhat.com>
Date: Thu, 29 Sep 2016 15:34:53 +0200
Subject: [PATCH] Solve problems with -l and -s options in repoquery
[x]$ sudo dnf repoquery dnf -l
Failed loading plugin: module
Last metadata expiration check: 2:23:07 ago on Thu Sep 29 20:56:24 2016 CEST.
Error: 'RepoQueryCommand' object has no attribute 'filelist_format'
[x]$ sudo dnf repoquery dnf --source
Failed loading plugin: module
Last metadata expiration check: 2:23:20 ago on Thu Sep 29 20:56:24 2016 CEST.
Error: 'RepoQueryCommand' object has no attribute 'sourcerpm_format'
Closes: #626
Approved by: ignatenkobrain
---
dnf/cli/commands/repoquery.py | 12 ++----------
tests/test_repoquery.py | 10 ++++++++--
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/dnf/cli/commands/repoquery.py b/dnf/cli/commands/repoquery.py
index cb6c7bd..5882669 100644
--- a/dnf/cli/commands/repoquery.py
+++ b/dnf/cli/commands/repoquery.py
@@ -57,14 +57,6 @@ OPTS_MAPPING = {
}
-def filelist_format(pkg):
- return pkg.files
-
-
-def sourcerpm_format(pkg):
- return pkg.sourcerpm
-
-
def rpm2py_format(queryformat):
"""Convert a rpm like QUERYFMT to an python .format() string."""
def fmt_repl(matchobj):
@@ -222,9 +214,9 @@ class RepoQueryCommand(commands.Command):
if opts.queryinfo:
return self.base.output.infoOutput(pkg)
elif opts.queryfilelist:
- return self.filelist_format(po)
+ return po.files
elif opts.querysourcerpm:
- return self.sourcerpm_format(po)
+ return po.sourcerpm
else:
return rpm2py_format(opts.queryformat).format(po)
diff --git a/tests/test_repoquery.py b/tests/test_repoquery.py
index b12bd97..e689263 100644
--- a/tests/test_repoquery.py
+++ b/tests/test_repoquery.py
@@ -99,14 +99,20 @@ class ArgParseTest(unittest.TestCase):
class FilelistFormatTest(unittest.TestCase):
def test_filelist(self):
+ self.cmd = dnf.cli.commands.repoquery.RepoQueryCommand(
+ support.CliStub(support.BaseCliStub()))
+ support.command_configure(self.cmd, ['-l'])
pkg = dnf.cli.commands.repoquery.PackageWrapper(PkgStub())
- self.assertEqual(dnf.cli.commands.repoquery.filelist_format(pkg),
+ self.assertEqual(self.cmd.build_format_fn(self.cmd.opts, pkg),
EXPECTED_FILELIST_FORMAT)
class SourceRPMFormatTest(unittest.TestCase):
def test_info(self):
+ self.cmd = dnf.cli.commands.repoquery.RepoQueryCommand(
+ support.CliStub(support.BaseCliStub()))
+ support.command_configure(self.cmd, ['--source'])
pkg = dnf.cli.commands.repoquery.PackageWrapper(PkgStub())
- self.assertEqual(dnf.cli.commands.repoquery.sourcerpm_format(pkg),
+ self.assertEqual(self.cmd.build_format_fn(self.cmd.opts, pkg),
EXPECTED_SOURCERPM_FORMAT)
class OutputTest(unittest.TestCase):
--
2.10.0