Skip to content

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

Description

@jmvrbanac

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'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions