But how would you know they all go under the same @fixture key?
*José Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Director of R&D On Tue, Jun 25, 2019 at 2:04 PM Allen Madsen <allen.c.mad...@gmail.com> wrote: > I don't have any problem with making it a separate function instead of an > option. > > I think the value of adding it for module level attributes is so that when > the attributes are combined into the context, the correct precedence is > maintained. > > Basically, it would be similar to this behavior: > https://github.com/elixir-lang/elixir/blob/v1.8.2/lib/ex_unit/lib/ex_unit/case.ex#L476-L477 > > I think maybe it wasn't obvious in my proposal, but in the example I gave, > @module_fixture, @describe_fixture, and @fixture would all go under the > context.registered.fixture key. That would replicate the behavior of tags > for registered attributes. > > Allen Madsen > http://www.allenmadsen.com > > > On Tue, Jun 25, 2019 at 1:31 AM José Valim < > jose.va...@plataformatec.com.br> wrote: > >> Hi Allen, good proposal! >> >> I don't believe we need to support these for module attributes, as there >> is no clean or book keeping to be done. >> >> My suggestion is to add a new register_describe_attribute with the same >> API as register_attribute. WDYT? >> >> *José Valim* >> www.plataformatec.com.br >> Skype: jv.ptec >> Founder and Director of R&D >> >> >> On Tue, Jun 25, 2019 at 3:52 AM Allen Madsen <bla...@gmail.com> wrote: >> >>> ExUnit supports tags at the test, describe, and module level. You can >>> easily add your own attribute with ExUnit.Case.register_attribute/3, >>> however, it only works at the test level. As it is, to simulate attributes >>> at the describe and module level, you'd have to replace parts of ExUnit or >>> require users to specify statements in a specific order so that more >>> specific attributes would override less specific ones. >>> >>> My proposal is to add a :for option to ExUnit.Case.register_attribute/3, >>> that allows you to specify the the level for the registered attribute. >>> >>> ExUnit.Case.register_attribute(__MODULE__, :fixture) # defaults to :test >>> ExUnit.Case.register_attribute(__MODULE__, :fixture, for: :test) >>> ExUnit.Case.register_attribute(__MODULE__, :describe_fixture, for: >>> :describe) >>> ExUnit.Case.register_attribute(__MODULE__, :module_fixture, for: :module) >>> >>> The attributes would have the same precedence rules as tags, where test >>> > describe > module. >>> >>> I'm happy to start work on this if it's deemed worthwhile. >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "elixir-lang-core" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to elixir-lang-core+unsubscr...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/elixir-lang-core/a6c52567-bac9-4513-a688-090358d407af%40googlegroups.com >>> <https://groups.google.com/d/msgid/elixir-lang-core/a6c52567-bac9-4513-a688-090358d407af%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "elixir-lang-core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to elixir-lang-core+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KFN7bLuTtLXpk9wMXm9HjGtDeqb4xomo1xfSvq3jAs8Q%40mail.gmail.com >> <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KFN7bLuTtLXpk9wMXm9HjGtDeqb4xomo1xfSvq3jAs8Q%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to elixir-lang-core+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/CAK-y3Ctu4bHjaO1A9%3DYc63znkTfB7BPxFUCOG8WG0pZo5iC2AQ%40mail.gmail.com > <https://groups.google.com/d/msgid/elixir-lang-core/CAK-y3Ctu4bHjaO1A9%3DYc63znkTfB7BPxFUCOG8WG0pZo5iC2AQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BNvxR-y0-tcueO9x00JuwpFA7H8P-Mqv5tV1FVNk%2B2hw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.