Oct-10-2018, 01:11 PM
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
I get the following output
I'm new to Python (and programming in general) and doing a Google search didn't resolve it thus far.
Many thanks in advance!
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
Output:============================= test session starts ==============================
platform darwin -- Python 3.7.0, pytest-3.0.3, py-1.6.0, pluggy-0.4.0
rootdir: /.../mattermost-helpdesk, inifile:
collected 0 items / 1 errors
==================================== ERRORS ====================================
_______________ ERROR collecting tests/test_discourse_wrapper.py _______________
ImportError while importing test module '/.../mattermost-helpdesk/tests/test_discourse_wrapper.py'.
Original error message:
'cannot import name 'session' from 'discourse_api_wrapper' (.../mattermost-helpdesk/discourse_api_wrapper/__init__.py)'
Make sure your test modules/packages have valid Python names.
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.36 seconds ============================
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!