Skip to content

Follow useful @testset behavior #51

@aplavin

Description

@aplavin

Currently, @testitem behaves quite different compared to regular @testset. It would be better to follow the latter as possible, at least in some useful ways:

  1. Early stopping. One can do return in @testset, and the testset stops executing. Meanwhile, return seems to be a no-op in @testitem, quite surprisingly.
  2. Local scope. @testset run in local scope, while @testitem seems to have global scope. This difference manifests itself, for example, with warning for innocuous code like
o = 1
...
for i in 1:5
    o = i
    ...
end

# warns:
# Warning: Assignment to `o` in soft scope is ambiguous because a global variable by the same name exists: `o` will be treated as a new local.

I think both can be solved by wrapping code generated by @testitem into let ... end blocks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions