diff --git a/tornado/concurrent.py b/tornado/concurrent.py index 2a0615621..e017ffd58 100644 --- a/tornado/concurrent.py +++ b/tornado/concurrent.py @@ -131,7 +131,7 @@ def wrapper(self: Any, *args: Any, **kwargs: Any) -> Future: if len(args) == 1: return run_on_executor_decorator(args[0]) elif len(args) != 0: - raise ValueError("expected 1 argument, got %d", len(args)) + raise ValueError("expected 1 argument, got %d" % len(args)) return run_on_executor_decorator diff --git a/tornado/test/concurrent_test.py b/tornado/test/concurrent_test.py index f376f87d5..4a1dc5e73 100644 --- a/tornado/test/concurrent_test.py +++ b/tornado/test/concurrent_test.py @@ -227,5 +227,15 @@ async def f(): self.assertEqual(result, 42) +class RunOnExecutorArgValidationTest(AsyncTestCase): + def test_run_on_executor_bad_args(self): + with self.assertRaisesRegex(ValueError, "expected 1 argument, got 2"): + @run_on_executor(1, 2) + def f(): + pass + + pass + + if __name__ == "__main__": unittest.main()