Having trouble setting up Python unittests with a Discord bot
I am having trouble setting up Python unittests with a Discord bot. Error message below.
I have two files, a main.py with the Discord code, and a calc.py with the bot code. I do not actually want to test the Discord code, but I cannot remove the "from main import *" line from the setup.
The problem seems to be with the TOKEN secret, and the loading of the environment. It doesn't get the TOKEN correctly, I think.
client.run(os.getenv('TOKEN'))
I have tried a couple of things, unsuccessfully so far. I haven't found any documentation on this yet. Does anyone have a tip for me on how to get this going?
Thanks in advance.
Error message:
Traceback (most recent call last):
File "_test_runnertest_runner.py", line 2, in
import _test_runnertest_suite
File "/home/runner/Level-Calc-Beta/_test_runnertest_suite.py", line 2, in
from main import *
File "/home/runner/Level-Calc-Beta/main.py", line 31, in
client.run(os.getenv('TOKEN'))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 702, in runner
await self.start(*args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 665, in start
await self.login(*args, bot=bot)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
AttributeError: 'NoneType' object has no attribute 'strip'
exit status 1
sus