Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
howroyd committed Aug 26, 2023
1 parent 4264dd1 commit 83a9380
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,5 +44,4 @@ jobs:
pip install .
- name: Test with pytest
run: |
pip install pytest pytest-cov
python run_tests.py
5 changes: 4 additions & 1 deletion src/twitchirc_drgreengiant/twitchirc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_twitch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!./.venv/bin/python3
import pytest

import twitchirc_drgreengiant as twitchirc
import twitchirc_drgreengiant.twitchirc as twitchirc

DEFAULT_CHANNELS = frozenset(["drgreengiant"])

Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 83a9380

Please sign in to comment.