title: globals() binds to module where it was declared instead of where it is used
body: <p>I am using a test framework that loads a module and then searches the scope of that module for <code>@test()</code> decorated function. What I am trying to do is to dynamically create those tests by dynamically creating those tagged variables.</p>
  
  <p>It looks like this:</p>
  
  <pre><code>for i in range(100):
      globals()[f"Test_{i}"] = test()(Test)
  </code></pre>
  
  <p>For convenience I wrapped this up into reusable function and stuck it in another module:</p>
  
  <pre><code>def add_test(t, n=1):
      for i in range(n):
          globals()[f"{t.__name__}_{i}"] = test()(t)
  </code></pre>
  
  <p>However, when I import the <code>add_test()</code> function in a test module, and call it, no new variables are added to the test modules's global scope. If I move this function into the module where it is used, it works. It seems like <code>globals()</code> binds to the module scope rather than a true global scope. Is that analysis correct? How do I work around this?</p>