Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error finding self when using expect() in a method that doesn't belong to the Spec #87

Open
jmvrbanac opened this issue Sep 9, 2016 · 1 comment
Labels

Comments

@jmvrbanac
Copy link
Owner

jmvrbanac commented Sep 9, 2016

Python Version: 3.4.5
Specter Version: 0.5.1

This seems to occur whenever an expectation is in a method that doesn't belong to the Spec. This following output doesn't really make sense, so we need to clean up this behavior so it gives a reasonable message to the developer.

Specter Output

  ∟ handles exceptions for work
      Error Traceback:
        - /home/john/.virtualenvs/project/lib/python3.4/site-packages/specter/spec.py
        ------------------
          82:         self.start()
          83:         try:
      --> 84:             types.MethodType(self.case_func, context or self)(**kwargs)
          85:         except TestIncompleteException as e:
        ------------------
        - /home/john/Repositories/project/spec/worker.py
        ------------------
          38:     def handles_exceptions_for_work(self):
          39:         worker = ExceptionWorker(None, None)
      --> 40:         run_worker_as_thread(worker)
          41: 
        ------------------
        - /home/john/Repositories/project/spec/worker.py
        ------------------
          48:         thread.join()
          49: 
      --> 50:         expect(worker.finished.is_set()).to.be_true()
        ------------------
        - /home/john/.virtualenvs/project/lib/python3.4/site-packages/specter/expect.py
        ------------------
          206:     :param caller_args: Is only used when using expecting a raised Exception
          207:     """
      --> 208:     line, module = get_module_and_line('__spec__')
          209:     src_params = ExpectParams(line, module)
        ------------------
        - /home/john/.virtualenvs/project/lib/python3.4/site-packages/specter/util.py
        ------------------
          90:         last_frame = last_frame.f_back
          91: 
      --> 92:     self = module = last_frame.f_locals['self']
          93:     # Use an attr instead of self
        ------------------
        - Error | KeyError: 'self'
@jmvrbanac jmvrbanac added the bug label Sep 9, 2016
@jmvrbanac jmvrbanac changed the title Error finding self when calling method in another thread that raises an exception Error finding self when using expect() in a method that doesn't belong to the Spec Sep 9, 2016
@jmvrbanac
Copy link
Owner Author

Clarified bug after running into it a second time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant