<commit_before>"""A module to test whether doctest recognizes some 2.2 features,
like static and class methods.

>>> print 'yup'  # 1
yup
"""

import test_support

# XXX The class docstring is skipped.
class C(object):
    """Class C.

    >>> print C()  # 2
    42
    """

    def __init__(self):
        """C.__init__.

        >>> print C() # 3
        42
        """

    def __str__(self):
        """
        >>> print C() # 4
        42
        """
        return "42"

    # XXX The class docstring is skipped.
    class D(object):
        """A nested D class.

        >>> print "In D!"   # 5
        In D!
        """

        def nested(self):
            """
            >>> print 3 # 6
            3
            """

    def getx(self):
        """
        >>> c = C()    # 7
        >>> c.x = 12   # 8
        >>> print c.x  # 9
        -12
        """
        return -self._x

    def setx(self, value):
        """
        >>> c = C()     # 10
        >>> c.x = 12    # 11
        >>> print c.x   # 12
        -12
        """
        self._x = value

    x = property(getx, setx, doc="""\
        >>> c = C()    # 13
        >>> c.x = 12   # 14
        >>> print c.x  # 15
        -12
        """)

    def statm():
        """
        A static method.

        >>> print C.statm()    # 16
        666
        >>> print C().statm()  # 17
        666
        """
        return 666

    statm = staticmethod(statm)

    def clsm(cls, val):
        """
        A class method.

        >>> print C.clsm(22)    # 18
        22
        >>> print C().clsm(22)  # 19
        22
        """
        return 22

    clsm = classmethod(clsm)

def test_main():
    import test_doctest2
    # XXX 2 class docstrings are skipped.
    # EXPECTED = 19
    EXPECTED = 17
    f, t = test_support.run_doctest(test_doctest2)
    if t != EXPECTED:
        raise test_support.TestFailed("expected %d tests to run, not %d" %
                                      (EXPECTED, t))

# Pollute the namespace with a bunch of imported functions and classes,
# to make sure they don't get tested.
from doctest import *

if __name__ == '__main__':
    test_main()
<commit_msg>Made the classmethod docstring test a bit less trivial.<commit_after>"""A module to test whether doctest recognizes some 2.2 features,
like static and class methods.

>>> print 'yup'  # 1
yup
"""

import test_support

# XXX The class docstring is skipped.
class C(object):
    """Class C.

    >>> print C()  # 2
    42
    """

    def __init__(self):
        """C.__init__.

        >>> print C() # 3
        42
        """

    def __str__(self):
        """
        >>> print C() # 4
        42
        """
        return "42"

    # XXX The class docstring is skipped.
    class D(object):
        """A nested D class.

        >>> print "In D!"   # 5
        In D!
        """

        def nested(self):
            """
            >>> print 3 # 6
            3
            """

    def getx(self):
        """
        >>> c = C()    # 7
        >>> c.x = 12   # 8
        >>> print c.x  # 9
        -12
        """
        return -self._x

    def setx(self, value):
        """
        >>> c = C()     # 10
        >>> c.x = 12    # 11
        >>> print c.x   # 12
        -12
        """
        self._x = value

    x = property(getx, setx, doc="""\
        >>> c = C()    # 13
        >>> c.x = 12   # 14
        >>> print c.x  # 15
        -12
        """)

    def statm():
        """
        A static method.

        >>> print C.statm()    # 16
        666
        >>> print C().statm()  # 17
        666
        """
        return 666

    statm = staticmethod(statm)

    def clsm(cls, val):
        """
        A class method.

        >>> print C.clsm(22)    # 18
        22
        >>> print C().clsm(23)  # 19
        23
        """
        return val

    clsm = classmethod(clsm)

def test_main():
    import test_doctest2
    # XXX 2 class docstrings are skipped.
    # EXPECTED = 19
    EXPECTED = 17
    f, t = test_support.run_doctest(test_doctest2)
    if t != EXPECTED:
        raise test_support.TestFailed("expected %d tests to run, not %d" %
                                      (EXPECTED, t))

# Pollute the namespace with a bunch of imported functions and classes,
# to make sure they don't get tested.
from doctest import *

if __name__ == '__main__':
    test_main()

{'fraction_non_alphanumeric': 0.13579116098007785, 'fraction_numerical': 0.03572246393405083, 'mean_word_length': 1.2989473684210526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 117, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '483183', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1364, 'n_words': 422}