def test_basic(self): ident = Identity() state = State(x=1, y='a', z=[1, 2, 3]) inp = copy.deepcopy(state) out = ident.run(state).result() self.assertEqual(inp, out) self.assertFalse(out is inp)
def test_interruptable(self): ident = Identity() state = State(x=1) out = ident.run(state, racing_context=True) # ident block should not finish done, not_done = futures.wait({out}, timeout=0.1) self.assertEqual(len(done), 0) self.assertEqual(len(not_done), 1) # until we stop it ident.stop() done, not_done = futures.wait({out}, timeout=0.1) self.assertEqual(len(done), 1) self.assertEqual(len(not_done), 0) self.assertEqual(out.result().x, 1)