def test_load_source(self): test_source = textwrap.dedent(u""" # coding=utf-8 def f(a): '日本語 Δθₜ ← Δθₜ₋₁ + ∇Q(sₜ, aₜ)(rₜ + γₜ₊₁ max Q(⋅))' return a + 1 """) module, _ = loader.load_source(test_source, delete_on_exit=True) self.assertEqual(module.f(1), 2) self.assertEqual(module.f.__doc__, '日本語 Δθₜ ← Δθₜ₋₁ + ∇Q(sₜ, aₜ)(rₜ + γₜ₊₁ max Q(⋅))')
def test_cleanup(self): test_source = textwrap.dedent('') _, filename = loader.load_source(test_source, delete_on_exit=True) # Clean up the file before loader.py tries to remove it, to check that the # latter can deal with that situation. os.unlink(filename)