Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-108303: Move all doctest related files and tests to Lib/test/test_doctest/ #112109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review, merge main
  • Loading branch information
sobolevn committed Dec 22, 2023
commit a13b649545a13b3b4cc0d053771c77b1aadb04c1
31 changes: 30 additions & 1 deletion 31 Lib/test/test_doctest/test_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ def get(self):
"""
return self.val

def setter(self, val):
"""
>>> s = SampleClass(-5)
>>> s.setter(1)
>>> print(s.val)
1
"""
self.val = val

def a_staticmethod(v):
"""
>>> print(SampleClass.a_staticmethod(10))
Expand All @@ -96,7 +105,7 @@ def a_classmethod(cls, v):
return v+2
a_classmethod = classmethod(a_classmethod)

a_property = property(get, doc="""
a_property = property(get, setter, doc="""
>>> print(SampleClass(22).a_property)
22
""")
Expand Down Expand Up @@ -519,6 +528,7 @@ def basics(): r"""
1 SampleClass.a_staticmethod
1 SampleClass.double
1 SampleClass.get
3 SampleClass.setter

New-style classes are also supported:

Expand Down Expand Up @@ -575,10 +585,25 @@ def basics(): r"""
1 some_module.SampleClass.a_staticmethod
1 some_module.SampleClass.double
1 some_module.SampleClass.get
3 some_module.SampleClass.setter
1 some_module.__test__.c
2 some_module.__test__.d
1 some_module.sample_func

However, doctest will ignore imported objects from other modules
(without proper `module=`):

>>> import types
>>> m = types.ModuleType('poluted_namespace')
>>> m.__dict__.update({
... 'sample_func': sample_func,
... 'SampleClass': SampleClass,
... })

>>> finder = doctest.DocTestFinder()
>>> finder.find(m)
[]

Duplicate Removal
~~~~~~~~~~~~~~~~~
If a single object is listed twice (under different names), then tests
Expand Down Expand Up @@ -617,6 +642,7 @@ def basics(): r"""
1 SampleClass.a_staticmethod
1 SampleClass.double
1 SampleClass.get
3 SampleClass.setter

By default, that excluded objects with no doctests. exclude_empty=False
tells it to include (empty) tests for objects with no doctests. This feature
Expand All @@ -638,6 +664,7 @@ def basics(): r"""
1 SampleClass.a_staticmethod
1 SampleClass.double
1 SampleClass.get
3 SampleClass.setter

When used with `exclude_empty=False` we are also interested in line numbers
of doctests that are empty.
Expand All @@ -652,9 +679,11 @@ def basics(): r"""
30 test.test_doctest.doctest_lineno.ClassWithDoctest
None test.test_doctest.doctest_lineno.ClassWithoutDocstring
None test.test_doctest.doctest_lineno.MethodWrapper
53 test.test_doctest.doctest_lineno.MethodWrapper.classmethod_with_doctest
39 test.test_doctest.doctest_lineno.MethodWrapper.method_with_docstring
45 test.test_doctest.doctest_lineno.MethodWrapper.method_with_doctest
None test.test_doctest.doctest_lineno.MethodWrapper.method_without_docstring
61 test.test_doctest.doctest_lineno.MethodWrapper.property_with_doctest
4 test.test_doctest.doctest_lineno.func_with_docstring
12 test.test_doctest.doctest_lineno.func_with_doctest
None test.test_doctest.doctest_lineno.func_without_docstring
Expand Down
126 changes: 0 additions & 126 deletions 126 Lib/test/test_doctest/test_doctest2.py

This file was deleted.

You are viewing a condensed version of this merge commit. You can view the full changes here.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.