FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update `test_setcomps.py` from 3.13.11 by ShaharNaveh · Pull Request #6425 · RustPython/RustPython · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
65 changes: 49 additions & 16 deletions Lib/test/test_setcomps.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import doctest
import traceback
import unittest

from test.support import BrokenIter


doctests = """
########### Tests mostly copied from test_listcomps.py ############

Expand Down Expand Up @@ -144,24 +151,50 @@

"""

class SetComprehensionTest(unittest.TestCase):
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: 'FrameSummary' object has no attribute 'end_lineno'
def test_exception_locations(self):
# The location of an exception raised from __init__ or
# __next__ should should be the iterator expression

def init_raises():
try:
{x for x in BrokenIter(init_raises=True)}
except Exception as e:
return e

def next_raises():
try:
{x for x in BrokenIter(next_raises=True)}
except Exception as e:
return e

def iter_raises():
try:
{x for x in BrokenIter(iter_raises=True)}
except Exception as e:
return e

for func, expected in [(init_raises, "BrokenIter(init_raises=True)"),
(next_raises, "BrokenIter(next_raises=True)"),
(iter_raises, "BrokenIter(iter_raises=True)"),
]:
with self.subTest(func):
exc = func()
f = traceback.extract_tb(exc.__traceback__)[0]
indent = 16
co = func.__code__
self.assertEqual(f.lineno, co.co_firstlineno + 2)
self.assertEqual(f.end_lineno, co.co_firstlineno + 2)
self.assertEqual(f.line[f.colno - indent : f.end_colno - indent],
expected)

__test__ = {'doctests' : doctests}

def test_main(verbose=None):
import sys
from test import support
from test import test_setcomps
support.run_doctest(test_setcomps, verbose)

# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
support.run_doctest(test_setcomps, verbose)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
def load_tests(loader, tests, pattern):
tests.addTest(doctest.DocTestSuite())
return tests


if __name__ == "__main__":
test_main(verbose=True)
unittest.main()
Loading

Back | FazBrowse Home | New Git URL