diff options
author | Yury Selivanov <yury@magic.io> | 2016-09-09 05:01:51 (GMT) |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2016-09-09 05:01:51 (GMT) |
commit | eb6364557f9bc4e6be29bb8a8f43308a0e080aba (patch) | |
tree | 05b7aed24dce255be67e7a60c021c319d13f43c9 /Lib/test/test_sys.py | |
parent | b96ef55d493aded2dea18b0208070bdfab4ceb73 (diff) | |
download | cpython-eb6364557f9bc4e6be29bb8a8f43308a0e080aba.zip cpython-eb6364557f9bc4e6be29bb8a8f43308a0e080aba.tar.gz cpython-eb6364557f9bc4e6be29bb8a8f43308a0e080aba.tar.bz2 |
Issue #28003: Implement PEP 525 -- Asynchronous Generators.
Diffstat (limited to 'Lib/test/test_sys.py')
-rw-r--r-- | Lib/test/test_sys.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index a6cd95e..37ee0b0 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1192,6 +1192,32 @@ class SizeofTest(unittest.TestCase): # sys.flags check(sys.flags, vsize('') + self.P * len(sys.flags)) + def test_asyncgen_hooks(self): + old = sys.get_asyncgen_hooks() + self.assertIsNone(old.firstiter) + self.assertIsNone(old.finalizer) + + firstiter = lambda *a: None + sys.set_asyncgen_hooks(firstiter=firstiter) + hooks = sys.get_asyncgen_hooks() + self.assertIs(hooks.firstiter, firstiter) + self.assertIs(hooks[0], firstiter) + self.assertIs(hooks.finalizer, None) + self.assertIs(hooks[1], None) + + finalizer = lambda *a: None + sys.set_asyncgen_hooks(finalizer=finalizer) + hooks = sys.get_asyncgen_hooks() + self.assertIs(hooks.firstiter, firstiter) + self.assertIs(hooks[0], firstiter) + self.assertIs(hooks.finalizer, finalizer) + self.assertIs(hooks[1], finalizer) + + sys.set_asyncgen_hooks(*old) + cur = sys.get_asyncgen_hooks() + self.assertIsNone(cur.firstiter) + self.assertIsNone(cur.finalizer) + def test_main(): test.support.run_unittest(SysModuleTest, SizeofTest) |