Skip to content

Commit 9822952

Browse files
committed
Do not warn for CaseTemplate options, closes #14077
1 parent a539395 commit 9822952

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

lib/ex_unit/lib/ex_unit/case.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ defmodule ExUnit.Case do
315315
end
316316
end
317317

318+
@keys [:async, :group, :parameterize, :register]
319+
320+
@doc false
321+
def __keys__(opts), do: Keyword.take(opts, @keys)
322+
318323
@doc false
319324
def __register__(module, opts) do
320325
if not Keyword.keyword?(opts) do
@@ -324,7 +329,7 @@ defmodule ExUnit.Case do
324329
end
325330

326331
{register?, opts} = Keyword.pop(opts, :register, true)
327-
{next_opts, opts} = Keyword.split(opts, [:async, :group, :parameterize])
332+
{next_opts, opts} = Keyword.split(opts, @keys)
328333

329334
if opts != [] do
330335
IO.warn("unknown options given to ExUnit.Case: #{inspect(opts)}")

lib/ex_unit/lib/ex_unit/case_template.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ defmodule ExUnit.CaseTemplate do
8383
# We inject this code in the module that calls "use MyTemplate".
8484
def __proxy__(module, opts) do
8585
quote do
86-
use ExUnit.Case, unquote(opts)
86+
use ExUnit.Case, ExUnit.Case.__keys__(unquote(opts))
8787

8888
setup_all context do
8989
unquote(module).__ex_unit__(:setup_all, context)

lib/ex_unit/test/ex_unit/case_template_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ defmodule ExUnit.NestedCase do
3636
end
3737

3838
defmodule ExUnit.CaseTemplateTest do
39-
use ExUnit.SampleCase, async: true
39+
use ExUnit.SampleCase, async: true, another_option: 123
4040
use ExUnit.NestedCase
4141

4242
two = 2

0 commit comments

Comments
 (0)