GNOME Bugzilla – Bug 740337
Improve usage of assertAlmostEqual()
Last modified: 2016-06-07 08:02:56 UTC
Test suite of pygobject sometimes passes "places" argument of assertAlmostEqual() as positional argument and sometimes as keyword argument. I suggest to always pass it as keyword argument. $ grep -r assertAlmostEqual * ChangeLog: assertAlmostEquals → assertAlmostEqual tests/test_gobject.py: self.assertAlmostEqual(value.get_value(), 1e50) tests/test_properties.py: self.assertAlmostEqual(self.get_prop(obj, 'some-float'), 42.42, 4) tests/test_properties.py: self.assertAlmostEqual(self.get_prop(obj, 'some-float'), 42.0, 4) tests/test_properties.py: self.assertAlmostEqual(self.get_prop(obj, 'some-float'), 42.0, 4) tests/test_properties.py: self.assertAlmostEqual(self.get_prop(obj, 'some-double'), 42.42) tests/test_properties.py: self.assertAlmostEqual(self.get_prop(obj, 'some-double'), 42.0) tests/test_properties.py: self.assertAlmostEqual(self.get_prop(obj, 'some-double'), 42.0) tests/test_everything.py: self.assertAlmostEqual(two, 5.0) tests/test_everything.py: self.assertAlmostEqual(three, 7.5) tests/test_signal.py: self.assertAlmostEqual(rv, 1.234, 4) tests/test_signal.py: self.assertAlmostEqual(rv, 1.234, 4) tests/test_gi.py: self.assertAlmostEqual(self.MAX, GIMarshallingTests.float_return()) tests/test_gi.py: self.assertAlmostEqual(self.MAX, GIMarshallingTests.float_out()) tests/test_gi.py: self.assertAlmostEqual(self.MIN, GIMarshallingTests.float_inout(Number(self.MAX))) tests/test_gi.py: self.assertAlmostEqual(self.MAX, GIMarshallingTests.double_return()) tests/test_gi.py: self.assertAlmostEqual(self.MAX, GIMarshallingTests.double_out()) tests/test_gi.py: self.assertAlmostEqual(self.MIN, GIMarshallingTests.double_inout(Number(self.MAX))) tests/test_gi.py: self.assertAlmostEqual(GIMarshallingTests.callback_one_out_parameter(cb), 5.5) tests/test_gi.py: self.assertAlmostEqual(res[0], 5.5) tests/test_gi.py: self.assertAlmostEqual(res[1], 42.0) tests/test_gi.py: self.assertAlmostEqual(res[1], 42.0) tests/test_gi.py: self.assertAlmostEqual(object_.vfunc_one_out_parameter(), 42.42, places=5) tests/test_gi.py: self.assertAlmostEqual(a, 42.42, places=5) tests/test_gi.py: self.assertAlmostEqual(b, 3.14, places=5)
Created attachment 290936 [details] [review] Patch
Review of attachment 290936 [details] [review]: I agree this is nicer, can you add a commit message? see: https://wiki.gnome.org/GnomeLove/SubmittingPatches https://wiki.gnome.org/Git/CommitMessages
Commit message: "Always pass 'places' argument of unittest.TestCase.assertAlmostEqual as keyword argument."
Created attachment 329227 [details] [review] tests: Use places kwarg for assertAlmostEqual