[Yum-devel] [PATCH] clean up misc.to_xml(), make it faster, add tests. BZ 716235.

David Malcolm dmalcolm at redhat.com
Fri Nov 16 18:14:26 UTC 2012


On Fri, 2012-11-16 at 14:47 +0100, Zdeněk Pavlas wrote:
> Returns valid UTF8, and the input is mostly UTF8, too.
> Avoid conversion to unicode, avoid saxutils.
> ---
>  test/misc-tests.py |   32 +++++++++++++++++++++
>  yum/misc.py        |   77 ++++++++++++++-------------------------------------
>  2 files changed, 53 insertions(+), 56 deletions(-)
> 
> diff --git a/test/misc-tests.py b/test/misc-tests.py
> index d34c161..9c62e24 100644
> --- a/test/misc-tests.py
> +++ b/test/misc-tests.py
> @@ -114,6 +114,38 @@ class MiscTests(DepsolveTests):
>          res, msg = solver.buildTransaction()
>          return self.res[res], msg
>  
> +    def testXML(self):
> +        import yum.misc


I'm so happy to see a patch that adds new test cases that to nitpick
seems somewhat churlish :)

However, wouldn't the following be cleaner by changing
the loop:
> +        for i in (

to be:

          for input_, expected in (

[...snip inputs...]

> +            i = list(i); ok = i.pop()
so that you can drop this manual unpacking and the *i later on (if I'm
reading it right).

With the above renamings the following:
> +            ret = yum.misc.to_xml(*i)
> +            self.assertEqual(type(ret), str)
> +            self.assertEqual(ret, ok)
would then become:
              actual = yum.misc.to_xml(input_)
              self.assertEqual(type(actual), str)
              self.assertEqual(actual, expected)
or somesuch.

(BTW "input" is a builtin, hence I used "input_" to avoid shadowing it)




More information about the Yum-devel mailing list