Running pytest gives " 'cannot import name 'session' " error - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Running pytest gives " 'cannot import name 'session' " error (/thread-13334.html) |
Running pytest gives " 'cannot import name 'session' " error - jasonblais - Oct-10-2018 I am writing a Python script, which returns topics from a Discourse forum based on a user-entered search query. CONTEXT To start, I've built an API wrapper for the Discourse API. The code is available here https://github.com/jasonblais/mattermost-helpdesk The structure is simple: . ├── requirements.txt ├── tests │ ├── test_discourse_wrapper.py // tests my wrapper is working as expected └── discourse_api_wrapper │ ├── __init__.py // initializer that creates a requests session used for all HTTP interactions with the Discourse API │ ├── discourse.py // creates a Discourse class, which makes an API call to Discourse and returns the response ISSUE To run the tests I execute this command from the root directory. Note that DISCOURSE_API_KEY is a parameter in discourse_api_wrapper/__init__.py DISCOURSE_API_KEY='<my-api-key>' python3 -m pytest tests/ I get the following output How do I resolve this error, or troubleshoot it?I'm new to Python (and programming in general) and doing a Google search didn't resolve it thus far. Many thanks in advance! RE: Running pytest gives " 'cannot import name 'session' " error - nilamo - Oct-10-2018 I don't know how you're getting that error, since you're not trying to import the session. Is the code on github the same code that generates the error? RE: Running pytest gives " 'cannot import name 'session' " error - jasonblais - Oct-10-2018 Thanks for the reply! It is the same code, I just pushed it upstream this morning to GitHub before creating this thread. Could I be missing a package I have to first install for Python? |