This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients Barry Devlin, rhettinger, terry.reedy
Date 2018-04-21.02:20:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1524277245.2.0.682650639539.issue33284@psf.upfronthosting.co.za>
In-reply-to
Content
Barry, thank you for your first submission.

You propose to test numbers.Complex.__bool__

    def __bool__(self):
        """True if self != 0. Called for bool(self)."""
        return self != 0

by adding the following to Lib/test/test_abstract_numbers.

+        self.assertFalse(bool(complex(0,0)))
+        self.assertTrue(bool(complex(1,2)))

I believe that this particular addition should be rejected.  It is a concrete test of the builtin complex that partially duplicates the following in test_complex.

    def test_boolcontext(self):
        for i in range(100):
            self.assertTrue(complex(random() + 1e-6, random() + 1e-6))
        self.assertTrue(not complex(0.0, 0.0))

Looking the tests of collections.abc in test_collections, I believe a proper test should define a subclass of Complex (in Python), with at least __init__ and __eq__ methods and test instances of *that*.

If I were to review a patch, I would like to see a more extensive addition, one that imports test_collections.ABCTestCase (or copies and adapts the same) and uses it to test a much fuller implementation of Complex.  As it is, none of the numbers abc class methods are tested.

Raymond, were you involved with the abc tests? Either way, what do you think?
History
Date User Action Args
2018-04-21 02:20:45terry.reedysetrecipients: + terry.reedy, rhettinger, Barry Devlin
2018-04-21 02:20:45terry.reedysetmessageid: <1524277245.2.0.682650639539.issue33284@psf.upfronthosting.co.za>
2018-04-21 02:20:45terry.reedylinkissue33284 messages
2018-04-21 02:20:43terry.reedycreate