Removed the Requirement to Install Python and NodeJS (Now Bundled with Borealis)

This commit is contained in:
2025-04-24 00:42:19 -06:00
parent 785265d3e7
commit 9c68cdea84
7786 changed files with 2386458 additions and 217 deletions

View File

@ -0,0 +1,5 @@
import os
from test.support import load_package_tests
def load_tests(*args):
return load_package_tests(os.path.dirname(__file__), *args)

View File

@ -0,0 +1,10 @@
# This module is used in `doctest_lineno.py`.
import functools
def decorator(f):
@functools.wraps(f)
def inner():
return f()
return inner

View File

@ -0,0 +1,13 @@
# Used by test_doctest.py.
class TwoNames:
'''f() and g() are two names for the same method'''
def f(self):
'''
>>> print(TwoNames().f())
f
'''
return 'f'
g = f # define an alias for f

View File

@ -0,0 +1,78 @@
# This module is used in `test_doctest`.
# It must not have a docstring.
def func_with_docstring():
"""Some unrelated info."""
def func_without_docstring():
pass
def func_with_doctest():
"""
This function really contains a test case.
>>> func_with_doctest.__name__
'func_with_doctest'
"""
return 3
class ClassWithDocstring:
"""Some unrelated class information."""
class ClassWithoutDocstring:
pass
class ClassWithDoctest:
"""This class really has a test case in it.
>>> ClassWithDoctest.__name__
'ClassWithDoctest'
"""
class MethodWrapper:
def method_with_docstring(self):
"""Method with a docstring."""
def method_without_docstring(self):
pass
def method_with_doctest(self):
"""
This has a doctest!
>>> MethodWrapper.method_with_doctest.__name__
'method_with_doctest'
"""
@classmethod
def classmethod_with_doctest(cls):
"""
This has a doctest!
>>> MethodWrapper.classmethod_with_doctest.__name__
'classmethod_with_doctest'
"""
@property
def property_with_doctest(self):
"""
This has a doctest!
>>> MethodWrapper.property_with_doctest.__name__
'property_with_doctest'
"""
# https://github.com/python/cpython/issues/99433
str_wrapper = object().__str__
# https://github.com/python/cpython/issues/115392
from test.test_doctest.decorator_mod import decorator
@decorator
@decorator
def func_with_docstring_wrapped():
"""Some unrelated info."""

View File

@ -0,0 +1,76 @@
"""This is a sample module that doesn't really test anything all that
interesting.
It simply has a few tests, some of which succeed and some of which fail.
It's important that the numbers remain constant as another test is
testing the running of these tests.
>>> 2+2
4
"""
def foo():
"""
>>> 2+2
5
>>> 2+2
4
"""
def bar():
"""
>>> 2+2
4
"""
def test_silly_setup():
"""
>>> import test.test_doctest.test_doctest
>>> test.test_doctest.test_doctest.sillySetup
True
"""
def w_blank():
"""
>>> if 1:
... print('a')
... print()
... print('b')
a
<BLANKLINE>
b
"""
x = 1
def x_is_one():
"""
>>> x
1
"""
def y_is_one():
"""
>>> y
1
"""
__test__ = {'good': """
>>> 42
42
""",
'bad': """
>>> 42
666
""",
}
def test_suite():
import doctest
return doctest.DocTestSuite()

View File

@ -0,0 +1,12 @@
# This is a sample module used for testing doctest.
#
# This module is for testing how doctest handles a module with no
# docstrings.
class Foo(object):
# A class with no docstring.
def __init__(self):
pass

View File

@ -0,0 +1,15 @@
"""This is a sample module used for testing doctest.
This module is for testing how doctest handles a module with docstrings
but no doctest examples.
"""
class Foo(object):
"""A docstring with no doctest examples.
"""
def __init__(self):
pass

View File

@ -0,0 +1,49 @@
"""This is a sample module used for testing doctest.
This module includes various scenarios involving skips.
"""
def no_skip_pass():
"""
>>> 2 + 2
4
"""
def no_skip_fail():
"""
>>> 2 + 2
5
"""
def single_skip():
"""
>>> 2 + 2 # doctest: +SKIP
4
"""
def double_skip():
"""
>>> 2 + 2 # doctest: +SKIP
4
>>> 3 + 3 # doctest: +SKIP
6
"""
def partial_skip_pass():
"""
>>> 2 + 2 # doctest: +SKIP
4
>>> 3 + 3
6
"""
def partial_skip_fail():
"""
>>> 2 + 2 # doctest: +SKIP
4
>>> 2 + 2
5
"""
def no_examples():
"""A docstring with no examples should not be counted as run or skipped."""

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,17 @@
This is a sample doctest in a text file.
In this example, we'll rely on a global variable being set for us
already:
>>> favorite_color
'blue'
We can make this fail by disabling the blank-line feature.
>>> if 1:
... print('a')
... print()
... print('b')
a
<BLANKLINE>
b

View File

@ -0,0 +1,126 @@
"""A module to test whether doctest recognizes some 2.2 features,
like static and class methods.
>>> print('yup') # 1
yup
We include some (random) encoded (utf-8) text in the text surrounding
the example. It should be ignored:
ЉЊЈЁЂ
"""
import sys
import unittest
if sys.flags.optimize >= 2:
raise unittest.SkipTest("Cannot test docstrings with -O2")
class C(object):
"""Class C.
>>> print(C()) # 2
42
We include some (random) encoded (utf-8) text in the text surrounding
the example. It should be ignored:
ЉЊЈЁЂ
"""
def __init__(self):
"""C.__init__.
>>> print(C()) # 3
42
"""
def __str__(self):
"""
>>> print(C()) # 4
42
"""
return "42"
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
""")
@staticmethod
def statm():
"""
A static method.
>>> print(C.statm()) # 16
666
>>> print(C().statm()) # 17
666
"""
return 666
@classmethod
def clsm(cls, val):
"""
A class method.
>>> print(C.clsm(22)) # 18
22
>>> print(C().clsm(23)) # 19
23
"""
return val
class Test(unittest.TestCase):
def test_testmod(self):
import doctest, sys
EXPECTED = 19
f, t = doctest.testmod(sys.modules[__name__])
if f:
self.fail("%d of %d doctests failed" % (f, t))
if t != EXPECTED:
self.fail("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__':
unittest.main()

View File

@ -0,0 +1,14 @@
This is a sample doctest in a text file.
In this example, we'll rely on some silly setup:
>>> import test.test_doctest.test_doctest
>>> test.test_doctest.test_doctest.sillySetup
True
This test also has some (random) encoded (utf-8) unicode text:
ЉЊЈЁЂ
This doesn't cause a problem in the tect surrounding the examples, but
we include it here (in this test text file) to make sure. :)

View File

@ -0,0 +1,5 @@
Here we check that `__file__` is provided:
>>> type(__file__)
<class 'str'>

View File

@ -0,0 +1,11 @@
This is a sample doctest in a text file that contains non-ASCII characters.
This file is encoded using UTF-8.
In order to get this test to pass, we have to manually specify the
encoding.
>>> 'föö'
'f\xf6\xf6'
>>> 'bąr'
'b\u0105r'

View File

@ -0,0 +1,4 @@
This is a sample doctest in a text file, in which all examples are skipped.
>>> 2 + 2 # doctest: +SKIP
5