After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 735193 - Unittests should be more granular
Unittests should be more granular
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2014-08-21 21:06 UTC by Simon Feltman
Modified: 2018-01-10 20:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
tests: Split test_strv() into multiple tests (1.38 KB, patch)
2014-09-11 23:23 UTC, Simon Feltman
committed Details | Review
tests: Split array tests up (3.75 KB, patch)
2014-09-12 02:10 UTC, Simon Feltman
committed Details | Review
Split test_everything.TestEverything.test_string() into multiple tests (2.45 KB, patch)
2014-09-12 02:33 UTC, Simon Feltman
committed Details | Review

Description Simon Feltman 2014-08-21 21:06:15 UTC
A lot of our unittests are large functions which test multiple units. These should be broken down into small single function tests. The advantage of this is it makes it easier to isolate failures and leaks when they occur. As an example [1]:

    def test_create_tuple(self):
        variant = GLib.Variant('()', ())
        self.assertEqual(variant.get_type_string(), '()')
        self.assertEqual(variant.n_children(), 0)

        variant = GLib.Variant('(i)', (3,))
        self.assertEqual(variant.get_type_string(), '(i)')
        self.assertTrue(isinstance(variant, GLib.Variant))
        self.assertEqual(variant.n_children(), 1)
        self.assertTrue(isinstance(variant.get_child_value(0), GLib.Variant))
        self.assertEqual(variant.get_child_value(0).get_int32(), 3)

        ...

This should be broken into multiple test functions:

    def test_create_tuple_empty(self):
        variant = GLib.Variant('()', ())
        self.assertEqual(variant.get_type_string(), '()')
        self.assertEqual(variant.n_children(), 0)

    def test_create_tuple_with_int32(self):
        variant = GLib.Variant('(i)', (3,))
        self.assertEqual(variant.get_type_string(), '(i)')
        self.assertTrue(isinstance(variant, GLib.Variant))
        self.assertEqual(variant.n_children(), 1)
        self.assertTrue(isinstance(variant.get_child_value(0), GLib.Variant))
        self.assertEqual(variant.get_child_value(0).get_int32(), 3)


This is somewhat systemic, so the whole tests suite should be audited.


[1] https://git.gnome.org/browse/pygobject/tree/tests/test_overrides_glib.py?id=3.13.90#n39
Comment 1 Simon Feltman 2014-09-11 23:23:52 UTC
The following fix has been pushed:
d1bae18 tests: Split test_strv() into multiple tests
Comment 2 Simon Feltman 2014-09-11 23:23:56 UTC
Created attachment 285966 [details] [review]
tests: Split test_strv() into multiple tests
Comment 3 Simon Feltman 2014-09-12 02:10:14 UTC
The following fix has been pushed:
6674701 tests: Split array tests up
Comment 4 Simon Feltman 2014-09-12 02:10:17 UTC
Created attachment 285974 [details] [review]
tests: Split array tests up

Split test_everything.TestEverything.test_array(), test_array_fixed_size(),
and test_ptrarray() into functions of a finer granularity. This allows for
easier diagnosis of problems and leaks when they occur.
Comment 5 Simon Feltman 2014-09-12 02:33:18 UTC
The following fix has been pushed:
a2f98a9 Split test_everything.TestEverything.test_string() into multiple tests
Comment 6 Simon Feltman 2014-09-12 02:33:21 UTC
Created attachment 285976 [details] [review]
Split test_everything.TestEverything.test_string() into multiple tests
Comment 7 GNOME Infrastructure Team 2018-01-10 20:45:20 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/80.