Uploaded image for project: 'The Virtual Brain'
  1. The Virtual Brain
  2. TVB-2924

Mock error using Python 3.8 environment

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.2.1
    • 2.4
    • None
    • None

    Description

      This error seems to only appear when using a Python 3.8 environment. I read about it on several places on the internet, for example here: https://www.gitmemory.com/issue/pallets/flask/3637/655372502.

      vb/tests/framework/interfaces/rest/datatype_resource_test.py:53 (TestDatatypeResource.test_server_retrieve_datatype_inexistent_gid)
      self = <tvb.tests.framework.interfaces.rest.datatype_resource_test.TestDatatypeResource object at 0x7fcc84668460>
      mocker = <pytest_mock.plugin.MockerFixture object at 0x7fcc84668580>
      
          def test_server_retrieve_datatype_inexistent_gid(self, mocker):
      >       self._mock_user(mocker)
      
      datatype_resource_test.py:55: 
      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      base_resource_test.py:36: in _mock_user
          request_mock = mocker.patch.object(flask, 'g')
      /Users/robert.vincze/opt/anaconda3/envs/tvb-st/lib/python3.8/site-packages/pytest_mock/plugin.py:197: in object
          return self._start_patch(
      /Users/robert.vincze/opt/anaconda3/envs/tvb-st/lib/python3.8/site-packages/pytest_mock/plugin.py:161: in _start_patch
          mocked = p.start()  # type: unittest.mock.MagicMock
      /Users/robert.vincze/opt/anaconda3/envs/tvb-st/lib/python3.8/unittest/mock.py:1529: in start
          result = self.__enter__()
      /Users/robert.vincze/opt/anaconda3/envs/tvb-st/lib/python3.8/unittest/mock.py:1416: in __enter__
          if spec is None and _is_async_obj(original):
      /Users/robert.vincze/opt/anaconda3/envs/tvb-st/lib/python3.8/unittest/mock.py:51: in _is_async_obj
          if hasattr(obj, '__func__'):
      /Users/robert.vincze/opt/anaconda3/envs/tvb-st/lib/python3.8/site-packages/werkzeug/local.py:348: in __getattr__
          return getattr(self._get_current_object(), name)
      /Users/robert.vincze/opt/anaconda3/envs/tvb-st/lib/python3.8/site-packages/werkzeug/local.py:307: in _get_current_object
          return self.__local()
      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      
      name = 'g'
      
          def _lookup_app_object(name):
              top = _app_ctx_stack.top
              if top is None:
      >           raise RuntimeError(_app_ctx_err_msg)
      E           RuntimeError: Working outside of application context.
      E           
      E           This typically means that you attempted to use functionality that needed
      E           to interface with the current application object in some way. To solve
      E           this, set up an application context with app.app_context().  See the
      E           documentation for more information.
      

      Gliffy Diagrams

        Attachments

          Activity

            People

              robert.vincze Robert Francisc Vincze
              robert.vincze Robert Francisc Vincze
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 1 day Original Estimate - 1 day
                  1d
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 4 hours
                  1d 4h