diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 6bed2fe..5640976 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -32,6 +32,7 @@ jobs: python -m pip install --upgrade pip pip install flake8 if (Test-Path requirements.txt) {pip install -r requirements.txt} + pip install pytest pytest-cov - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names @@ -43,5 +44,4 @@ jobs: pip install . - name: Test with pytest run: | - pip install pytest pytest-cov python run_tests.py diff --git a/src/twitchirc_drgreengiant/twitchirc.py b/src/twitchirc_drgreengiant/twitchirc.py index 94fbeb1..f12b59b 100644 --- a/src/twitchirc_drgreengiant/twitchirc.py +++ b/src/twitchirc_drgreengiant/twitchirc.py @@ -225,6 +225,8 @@ def __init__(self, username: str | None = None, oauth: str | None = None, timeout: float = None): + if not channel or channel.issubset(frozenset([""])): + raise TwitchIrcConnectionError("No channels specified") self._processdata = IrcThreadArgs( address=("irc.chat.twitch.tv", 6667), timeout=0.25, @@ -280,7 +282,8 @@ def get_message(irc: Self, *, timeout: float = 0.1) -> TwitchMessage | None: if __name__ == "__main__": - testchannels = frozenset(["drgreengiant"]) + testchannels = frozenset([""]) + #testchannels = frozenset(["drgreengiant"]) with TwitchIrc(testchannels) as irc: while True: diff --git a/tests/test_twitch.py b/tests/test_twitch.py index 699e7e6..d6b9978 100644 --- a/tests/test_twitch.py +++ b/tests/test_twitch.py @@ -1,7 +1,7 @@ #!./.venv/bin/python3 import pytest -import twitchirc_drgreengiant as twitchirc +import twitchirc_drgreengiant.twitchirc as twitchirc DEFAULT_CHANNELS = frozenset(["drgreengiant"]) @@ -39,14 +39,14 @@ def test_message_enum(): assert val == ret, f"Failed to parse \"{key}\" into {val}: got {ret}" -def channel_connection(channel: str): +def channel_connection(channel: frozenset[str]): with twitchirc.TwitchIrc(channel) as irc: assert irc.connected, "Thought we were connected but flag isnt set" def test_bad_channel_connection(): with pytest.raises(twitchirc.TwitchIrcConnectionError): - channel_connection("") + channel_connection(frozenset([""])) def test_good_channel_connection():