For what reason would a Flask application run fine, but fail to load a module in the unittest?

49 Views Asked by At

So, I created a small flask API. Basically a wrapper for another API. I used requests-futures to send multiple calls asynchronously.

I set up my virtual environment. Everything works exactly as I intend. However, when I try to run some tests I've written (using python -m unittest) this is the error I get:

======================================================================
ERROR: test (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/home/cwverica/take-home-apps/quixr/test.py", line 2, in <module>
    from app import app, session
  File "/home/cwverica/take-home-apps/quixr/app.py", line 3, in <module>
    from requests_futures.sessions import FuturesSession
ModuleNotFoundError: No module named 'requests_futures'

I have reinstalled the module using pip. I made sure to pip freeze > requirements.txt just in case it was reading module availability from there. But all in all I'm stumped. If anyone could help me out here, I'd greatly appreciate it.

0

There are 0 best solutions below