Ticket #6343: trac_6343-reviewer.patch

File trac_6343-reviewer.patch, 4.5 KB (added by mvngu, 10 years ago)

reviewer patch; fixes typos and docstring formatting

  • sage/misc/sage_unittest.py

    # HG changeset patch
    # User Minh Van Nguyen <nguyenminh2@gmail.com>
    # Date 1247788231 25200
    # Node ID 50d1d5aa7e7b3115d586a67342f55d8ac2537ea0
    # Parent  967ff1d37786455fef05e9fda214a0253fd595ef
    trac 6343: reviewer patch; fix typos and some docstring formatting
    
    diff -r 967ff1d37786 -r 50d1d5aa7e7b sage/misc/sage_unittest.py
    a b  
    2828        running ._test_not_implemented_methods() ... done
    2929        running ._test_pickling() ... done
    3030
    31     Those methods methods are typically implemented by abstract
     31    Those methods are typically implemented by abstract
    3232    super classes, in particular via categories, in order to
    3333    enforce standard behavior and API, or provide mathematical
    3434    sanity checks. For example if ``self`` is in the category of
     
    5353
    5454    When meaningful, one can further customize on which elements
    5555    the tests are run. Here, we use it to *prove* that the
    56     multiplication is indeed associative, by runing the test on
     56    multiplication is indeed associative, by running the test on
    5757    all the elements::
    5858
    5959        sage: S._test_associativity(elements = S)       # todo: not implemented (comes with the category patches)
    6060
    6161    Adding a new test boils down to adding a new method in the
    62     class of the object or any superclass (e.g. in a
     62    class of the object or any super class (e.g. in a
    6363    category). This method should use the utility :meth:`._tester`
    6464    to handle standard options and report test failures. See the
    6565    code of :meth:`._test_an_element` for an example.
    6666
    6767    Eventually, every implementation of a :class:`SageObject`
    68     should run a :class:`TestSuite` on one of its instances in its doctest.
    69     (replacing the current ``loads(dumps(x))` tests).
     68    should run a :class:`TestSuite` on one of its instances in its doctest
     69    (replacing the current ``loads(dumps(x))`` tests).
    7070
    7171    TODO:
    7272     - allow for customized behavior in case of failing assertion
    73        (warning, error, statistic accounting)
     73       (warning, error, statistic accounting).
    7474       This involves reimplementing the method sfail / failIf
    7575       / ... of unittest.TestCase in InstanceTester
    7676     - Improve integration with doctests (statistics on failing/passing tests)
     
    8181       test method to choose appropriately the elements so as to
    8282       prove the desired property. The test method may assume that
    8383       a parent implements properly all the super categories. For
    84        example, the test_commutative method of the category
     84       example, the ``test_commutative`` method of the category
    8585       ``CommutativeSemigroups()`` may just check that the
    8686       provided generators commute, implicitly assuming that
    8787       generators indeed generate the semigroup (as required by
     
    133133                tester.info("done")
    134134
    135135class InstanceTester(unittest.TestCase):
     136    """
     137    A gadget attached to an instance providing it with testing utilities.
     138
     139    EXAMPLES::
     140       
     141        sage: from sage.misc.sage_unittest import InstanceTester
     142        sage: InstanceTester(instance = ZZ, verbose = True, elements = [1,2,3])
     143        Testing utilities for Integer Ring
     144
     145    This is used by ``SageObject._tester``, which see::
     146
     147        sage: ZZ._tester()
     148        Testing utilities for Integer Ring
     149    """
     150
    136151    def __init__(self, instance, elements = None, verbose = False, **options):
    137152        """
    138153        A gadget attached to an instance providing it with testing utilities.
     
    147162
    148163            sage: ZZ._tester()
    149164            Testing utilities for Integer Ring
    150 
    151165        """
    152166        self._instance = instance
    153167        self._verbose = verbose
  • sage/structure/sage_object.pyx

    diff -r 967ff1d37786 -r 50d1d5aa7e7b sage/structure/sage_object.pyx
    a b  
    274274
    275275    def _tester(self, tester = None, **options):
    276276        """
    277         Returns a gadget attached to ``self`` providing testing utilities
     277        Returns a gadget attached to ``self`` providing testing utilities.
    278278
    279         This is used by :class:`sage.misc.sage_unittest.TestSuite` and the _test_* methods.
     279        This is used by :class:`sage.misc.sage_unittest.TestSuite` and the
     280        ``_test_*`` methods.
    280281
    281282        EXAMPLES::
    282283
     
    302303        :class:`unittest.TestCase`, which see (actually, by a slight
    303304        abuse, tester is currently an instance of this class).
    304305
    305         TESTS:
     306        TESTS::
    306307
    307308            sage: ZZ._tester(tester = tester) is tester
    308309            True