diff --git a/test/test_pep380.py b/test/test_pep380.py index 69194df9..11d65949 100644 --- a/test/test_pep380.py +++ b/test/test_pep380.py @@ -11,7 +11,7 @@ import unittest import io import sys import inspect -import parser +#import parser from test.support import captured_stderr, disable_gc, gc_collect @@ -288,7 +288,8 @@ class TestPEP380Operation(unittest.TestCase): g.close() except ValueError as e: self.assertEqual(e.args[0], "nybbles have exploded with delight") - self.assertIsInstance(e.__context__, GeneratorExit) +# MicroPython doesn't support nested exceptions +# self.assertIsInstance(e.__context__, GeneratorExit) else: self.fail("subgenerator failed to raise ValueError") self.assertEqual(trace,[ @@ -352,15 +353,16 @@ class TestPEP380Operation(unittest.TestCase): pex(e) e = StopIteration("spam") pex(e) - e.value = "eggs" - pex(e) +# MicroPython doesn't support assignment to .value +# e.value = "eggs" +# pex(e) self.assertEqual(trace,[ "StopIteration: ", "value = None", "StopIteration: spam", "value = spam", - "StopIteration: spam", - "value = eggs", +# "StopIteration: spam", +# "value = eggs", ]) @@ -554,11 +556,13 @@ class TestPEP380Operation(unittest.TestCase): self.assertEqual(next(gi), 1) gi.throw(AttributeError) - with captured_stderr() as output: - gi = g() - self.assertEqual(next(gi), 1) - gi.close() - self.assertIn('ZeroDivisionError', output.getvalue()) +# In MicroPython, exceptions is .close() are not ignored/printed to sys.stderr, +# but propagated as usual. +# with captured_stderr() as output: +# gi = g() +# self.assertEqual(next(gi), 1) +# gi.close() +# self.assertIn('ZeroDivisionError', output.getvalue()) def test_exception_in_initial_next_call(self): """ @@ -579,6 +583,7 @@ class TestPEP380Operation(unittest.TestCase): "g1 about to yield from g2" ]) + @unittest.skip("MicroPython doesn't check for already active generator when resuming it") def test_attempted_yield_from_loop(self): """ Test attempted yield-from loop @@ -834,7 +839,7 @@ class TestPEP380Operation(unittest.TestCase): gi.throw(GeneratorExit) except ValueError as e: self.assertEqual(e.args[0], "Vorpal bunny encountered") - self.assertIsInstance(e.__context__, GeneratorExit) +# self.assertIsInstance(e.__context__, GeneratorExit) else: self.fail("subgenerator failed to raise ValueError") self.assertEqual(trace,[ @@ -847,6 +852,7 @@ class TestPEP380Operation(unittest.TestCase): yield from () self.assertRaises(StopIteration, next, g()) + @unittest.skip("MicroPython doesn't check for already active generator when resuming it") def test_delegating_generators_claim_to_be_running(self): # Check with basic iteration def one(): @@ -919,6 +925,7 @@ class TestPEP380Operation(unittest.TestCase): next(g1) g1.close() + @unittest.skip("MicroPython doesn't support inspect.stack()") def test_delegator_is_visible_to_debugger(self): def call_stack(): return [f[3] for f in inspect.stack()]