diff --git a/lib/ex_unit/lib/ex_unit/case.ex b/lib/ex_unit/lib/ex_unit/case.ex index 0a61ae7441..21701d870d 100644 --- a/lib/ex_unit/lib/ex_unit/case.ex +++ b/lib/ex_unit/lib/ex_unit/case.ex @@ -315,6 +315,11 @@ defmodule ExUnit.Case do end end + @keys [:async, :group, :parameterize, :register] + + @doc false + def __keys__(opts), do: Keyword.take(opts, @keys) + @doc false def __register__(module, opts) do if not Keyword.keyword?(opts) do @@ -324,7 +329,7 @@ defmodule ExUnit.Case do end {register?, opts} = Keyword.pop(opts, :register, true) - {next_opts, opts} = Keyword.split(opts, [:async, :group, :parameterize]) + {next_opts, opts} = Keyword.split(opts, @keys) if opts != [] do IO.warn("unknown options given to ExUnit.Case: #{inspect(opts)}") diff --git a/lib/ex_unit/lib/ex_unit/case_template.ex b/lib/ex_unit/lib/ex_unit/case_template.ex index 0e4023a8ff..2449b7c199 100644 --- a/lib/ex_unit/lib/ex_unit/case_template.ex +++ b/lib/ex_unit/lib/ex_unit/case_template.ex @@ -83,7 +83,7 @@ defmodule ExUnit.CaseTemplate do # We inject this code in the module that calls "use MyTemplate". def __proxy__(module, opts) do quote do - use ExUnit.Case, unquote(opts) + use ExUnit.Case, ExUnit.Case.__keys__(unquote(opts)) setup_all context do unquote(module).__ex_unit__(:setup_all, context) diff --git a/lib/ex_unit/test/ex_unit/case_template_test.exs b/lib/ex_unit/test/ex_unit/case_template_test.exs index b5265a8ce5..d660a32eb8 100644 --- a/lib/ex_unit/test/ex_unit/case_template_test.exs +++ b/lib/ex_unit/test/ex_unit/case_template_test.exs @@ -36,7 +36,7 @@ defmodule ExUnit.NestedCase do end defmodule ExUnit.CaseTemplateTest do - use ExUnit.SampleCase, async: true + use ExUnit.SampleCase, async: true, another_option: 123 use ExUnit.NestedCase two = 2