Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ Lib/site-packages/*
!Lib/site-packages/README.txt
Lib/test/data/*
!Lib/test/data/README
cpython/
84 changes: 43 additions & 41 deletions Lib/test/test_warnings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def test_stacklevel(self):
self.assertEqual(os.path.basename(w[-1].filename),
"<sys>")

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_stacklevel_import(self):
# Issue #24305: With stacklevel=2, module-level warnings should work.
import_helper.unload('test.test_warnings.data.import_warning')
Expand Down Expand Up @@ -807,40 +807,40 @@ class CWarnTests(WarnTests, unittest.TestCase):

# As an early adopter, we sanity check the
# test.import_helper.import_fresh_module utility function
@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_accelerated(self):
self.assertIsNot(original_warnings, self.module)
self.assertNotHasAttr(self.module.warn, '__code__')

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_gh86298_loader_and_spec_loader_disagree(self):
return super().test_gh86298_loader_and_spec_loader_disagree()

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_gh86298_loader_is_none_and_spec_is_none(self):
return super().test_gh86298_loader_is_none_and_spec_is_none()

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_gh86298_loader_is_none_and_spec_loader_is_none(self):
return super().test_gh86298_loader_is_none_and_spec_loader_is_none()

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_gh86298_no_loader_and_no_spec_loader(self):
return super().test_gh86298_no_loader_and_no_spec_loader()

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_gh86298_no_loader_and_spec_is_none(self):
return super().test_gh86298_no_loader_and_spec_is_none()

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_gh86298_no_spec(self):
return super().test_gh86298_no_spec()

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_gh86298_no_spec_loader(self):
return super().test_gh86298_no_spec_loader()

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_gh86298_spec_is_none(self):
return super().test_gh86298_spec_is_none()

Expand Down Expand Up @@ -919,7 +919,7 @@ class _WarningsTests(BaseTest, unittest.TestCase):

module = c_warnings

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_filter(self):
# Everything should function even if 'filters' is not in warnings.
with self.module.catch_warnings() as w:
Expand All @@ -930,7 +930,7 @@ def test_filter(self):
self.assertRaises(UserWarning, self.module.warn,
'convert to error')

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_onceregistry(self):
# Replacing or removing the onceregistry should be okay.
global __warningregistry__
Expand Down Expand Up @@ -960,7 +960,7 @@ def test_onceregistry(self):
finally:
self.module.onceregistry = original_registry

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_default_action(self):
# Replacing or removing defaultaction should be okay.
message = UserWarning("defaultaction test")
Expand Down Expand Up @@ -1012,7 +1012,7 @@ def test_showwarning_missing(self):
result = stream.getvalue()
self.assertIn(text, result)

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_showwarnmsg_missing(self):
# Test that _showwarnmsg() missing is okay.
text = 'del _showwarnmsg test'
Expand Down Expand Up @@ -1092,7 +1092,7 @@ def test_stderr_none(self):
self.assertNotIn(b'Warning!', stderr)
self.assertNotIn(b'Error', stderr)

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_issue31285(self):
# warn_explicit() should neither raise a SystemError nor cause an
# assertion failure, in case the return value of get_source() has a
Expand Down Expand Up @@ -1245,7 +1245,7 @@ class CWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase):
class PyWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase):
module = py_warnings

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_tracemalloc(self):
self.addCleanup(os_helper.unlink, os_helper.TESTFN)

Expand Down Expand Up @@ -1458,15 +1458,15 @@ class PyCatchWarningTests(CatchWarningTests, unittest.TestCase):

class EnvironmentVariableTests(BaseTest):

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_single_warning(self):
rc, stdout, stderr = assert_python_ok("-c",
"import sys; sys.stdout.write(str(sys.warnoptions))",
PYTHONWARNINGS="ignore::DeprecationWarning",
PYTHONDEVMODE="")
self.assertEqual(stdout, b"['ignore::DeprecationWarning']")

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_comma_separated_warnings(self):
rc, stdout, stderr = assert_python_ok("-c",
"import sys; sys.stdout.write(str(sys.warnoptions))",
Expand All @@ -1475,7 +1475,7 @@ def test_comma_separated_warnings(self):
self.assertEqual(stdout,
b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']")

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
@force_not_colorized
def test_envvar_and_command_line(self):
rc, stdout, stderr = assert_python_ok("-Wignore::UnicodeWarning", "-c",
Expand All @@ -1485,7 +1485,7 @@ def test_envvar_and_command_line(self):
self.assertEqual(stdout,
b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']")

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
@force_not_colorized
def test_conflicting_envvar_and_command_line(self):
rc, stdout, stderr = assert_python_failure("-Werror::DeprecationWarning", "-c",
Expand Down Expand Up @@ -1535,7 +1535,7 @@ def test_default_filter_configuration(self):
self.assertEqual(stdout_lines, expected_output)


@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.skipUnless(sys.getfilesystemencoding() != 'ascii',
'requires non-ascii filesystemencoding')
def test_nonascii(self):
Expand All @@ -1549,8 +1549,10 @@ def test_nonascii(self):

class CEnvironmentVariableTests(EnvironmentVariableTests, unittest.TestCase):
module = c_warnings
@unittest.expectedFailure # TODO: RUSTPYTHON Lists differ
def test_default_filter_configuration(self): super().test_default_filter_configuration() # TODO: RUSTPYTHON

@unittest.expectedFailure # TODO: RUSTPYTHON; Lists differ
def test_default_filter_configuration(self):
return super().test_default_filter_configuration()

class PyEnvironmentVariableTests(EnvironmentVariableTests, unittest.TestCase):
module = py_warnings
Expand Down Expand Up @@ -1621,7 +1623,7 @@ def test_issue_8766(self):


class FinalizationTest(unittest.TestCase):
@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_finalization(self):
# Issue #19421: warnings.warn() should not crash
# during Python finalization
Expand All @@ -1639,7 +1641,7 @@ def __del__(self):
self.assertEqual(err.decode().rstrip(),
'<string>:7: UserWarning: test')

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_late_resource_warning(self):
# Issue #21925: Emitting a ResourceWarning late during the Python
# shutdown must be logged.
Expand Down Expand Up @@ -1849,7 +1851,7 @@ def h(x):
self.assertEqual(len(overloads), 2)
self.assertEqual(overloads[0].__deprecated__, "no more ints")

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_class(self):
@deprecated("A will go away soon")
class A:
Expand All @@ -1861,7 +1863,7 @@ class A:
with self.assertRaises(TypeError):
A(42)

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_class_with_init(self):
@deprecated("HasInit will go away soon")
class HasInit:
Expand All @@ -1872,7 +1874,7 @@ def __init__(self, x):
instance = HasInit(42)
self.assertEqual(instance.x, 42)

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_class_with_new(self):
has_new_called = False

Expand All @@ -1891,7 +1893,7 @@ def __init__(self, x) -> None:
self.assertEqual(instance.x, 42)
self.assertTrue(has_new_called)

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_class_with_inherited_new(self):
new_base_called = False

Expand All @@ -1913,7 +1915,7 @@ class HasInheritedNew(NewBase):
self.assertEqual(instance.x, 42)
self.assertTrue(new_base_called)

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_class_with_new_but_no_init(self):
new_called = False

Expand All @@ -1931,7 +1933,7 @@ def __new__(cls, x):
self.assertEqual(instance.x, 42)
self.assertTrue(new_called)

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_mixin_class(self):
@deprecated("Mixin will go away soon")
class Mixin:
Expand All @@ -1948,7 +1950,7 @@ class Child(Base, Mixin):
instance = Child(42)
self.assertEqual(instance.a, 42)

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_do_not_shadow_user_arguments(self):
new_called = False
new_called_cls = None
Expand All @@ -1968,7 +1970,7 @@ class Foo(metaclass=MyMeta, cls='haha'):
self.assertTrue(new_called)
self.assertEqual(new_called_cls, 'haha')

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_existing_init_subclass(self):
@deprecated("C will go away soon")
class C:
Expand All @@ -1985,7 +1987,7 @@ class D(C):
self.assertTrue(D.inited)
self.assertIsInstance(D(), D) # no deprecation

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_existing_init_subclass_in_base(self):
class Base:
def __init_subclass__(cls, x) -> None:
Expand All @@ -2006,7 +2008,7 @@ class D(C, x=3):

self.assertEqual(D.inited, 3)

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_existing_init_subclass_in_sibling_base(self):
@deprecated("A will go away soon")
class A:
Expand All @@ -2026,7 +2028,7 @@ class D(B, A, x=42):
pass
self.assertEqual(D.inited, 42)

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_init_subclass_has_correct_cls(self):
init_subclass_saw = None

Expand All @@ -2044,7 +2046,7 @@ class C(Base):

self.assertIs(init_subclass_saw, C)

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_init_subclass_with_explicit_classmethod(self):
init_subclass_saw = None

Expand All @@ -2063,7 +2065,7 @@ class C(Base):

self.assertIs(init_subclass_saw, C)

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_function(self):
@deprecated("b will go away soon")
def b():
Expand All @@ -2072,7 +2074,7 @@ def b():
with self.assertWarnsRegex(DeprecationWarning, "b will go away soon"):
b()

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_method(self):
class Capybara:
@deprecated("x will go away soon")
Expand All @@ -2083,7 +2085,7 @@ def x(self):
with self.assertWarnsRegex(DeprecationWarning, "x will go away soon"):
instance.x()

@unittest.expectedFailure # TODO: RUSTPYTHON DeprecationWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; DeprecationWarning not triggered
def test_property(self):
class Capybara:
@property
Expand Down Expand Up @@ -2111,7 +2113,7 @@ def no_more_setting(self, value):
with self.assertWarnsRegex(DeprecationWarning, "no more setting"):
instance.no_more_setting = 42

@unittest.expectedFailure # TODO: RUSTPYTHON RuntimeWarning not triggered
@unittest.expectedFailure # TODO: RUSTPYTHON; RuntimeWarning not triggered
def test_category(self):
@deprecated("c will go away soon", category=RuntimeWarning)
def c():
Expand Down
Loading