Skip to content

Commit

Permalink
Merge pull request #54 from praw-dev/fixes_for_3.6
Browse files Browse the repository at this point in the history
Fix tests for Python 3.6 and 3.7
  • Loading branch information
LilSpazJoekp committed Feb 8, 2021
2 parents e0d712f + f1a610b commit cde3698
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 44 deletions.
38 changes: 1 addition & 37 deletions .github/workflows/ci.yml
Expand Up @@ -7,7 +7,6 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

lint-multi-os:
name: Lint ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -43,41 +42,6 @@ jobs:
matrix:
os: [macOS-latest, ubuntu-latest, windows-latest]

lint-multi-python:
name: Lint Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.x
- uses: actions/cache@v1
with:
key: v0-${{ runner.os }}-pip-lint-${{ hashFiles('setup.py') }}
path: ~/.cache/pip
restore-keys: |
v0-${{ runner.os }}-pip-lint-
v0-${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[lint]
- name: Check other phrase usages
run: python ./tools/static_word_checks.py
- name: Run black
run: black --check --verbose .
- name: Run flake8
run: flake8 --exclude docs --statistics
- name: Check documentation
run: python ./tools/check_documentation.py
- name: Run pydocstyle
run: pydocstyle asyncpraw
- name: Run sphinx
run: sphinx-build --keep-going docs/ /tmp/foo
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]

test-multi-os:
name: Test ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -111,7 +75,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.x
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v1
with:
key: v0-${{ runner.os }}-pip-test-${{ hashFiles('setup.py') }}
Expand Down
2 changes: 1 addition & 1 deletion asyncpraw/models/reddit/multi.py
Expand Up @@ -222,7 +222,7 @@ async def remove(self, subreddit: Subreddit):

async def update(
self,
**updated_settings: Union[str, List[Union[str, Subreddit, Dict[str, str]]]]
**updated_settings: Union[str, List[Union[str, Subreddit, Dict[str, str]]]],
):
"""Update this multireddit.
Expand Down
17 changes: 14 additions & 3 deletions tests/integration/models/reddit/test_modmail.py
@@ -1,3 +1,4 @@
import sys
from datetime import datetime
from asynctest import mock

Expand Down Expand Up @@ -46,9 +47,19 @@ async def test_mute_duration(self, _):
await conversation.mute(7)
conversation = await subreddit.modmail("g46rw")
assert conversation.user.mute_status["isMuted"]
diff = datetime.fromisoformat(
conversation.user.mute_status["endDate"]
) - datetime.fromisoformat(conversation.mod_actions[-1].date)
if sys.version_info >= (3, 7, 0):
diff = datetime.fromisoformat(
conversation.user.mute_status["endDate"]
) - datetime.fromisoformat(conversation.mod_actions[-1].date)
else:
end_date = "".join(
conversation.user.mute_status["endDate"].rsplit(":", 1)
)
start_date = "".join(conversation.mod_actions[-1].date.rsplit(":", 1))
date_format = "%Y-%m-%dT%H:%M:%S.%f%z"
diff = datetime.strptime(end_date, date_format) - datetime.strptime(
start_date, date_format
)
assert diff.days == 6 # 6 here because it is not 7 whole days

@mock.patch("asyncio.sleep", return_value=None)
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/models/reddit/test_subreddit.py
Expand Up @@ -1653,8 +1653,7 @@ async def test_opt_out(self, _):
class TestSubredditRelationships(IntegrationTest):
REDDITOR = "pyapitestuser3"

@mock.patch("asyncio.sleep", return_value=None)
async def add_remove(self, base, user, relationship, _):
async def add_remove(self, base, user, relationship):
relationship = getattr(base, relationship)
await relationship.add(user)
relationships = await self.async_list(relationship())
Expand Down Expand Up @@ -1786,7 +1785,8 @@ async def test_moderator__user_filter(self):
assert len(moderator) == 1
assert "mod_permissions" in moderator[0].__dict__

async def test_muted(self):
@mock.patch("asyncio.sleep", return_value=None)
async def test_muted(self, _):
self.reddit.read_only = False
subreddit = await self.reddit.subreddit(pytest.placeholders.test_subreddit)
with self.use_cassette():
Expand Down

0 comments on commit cde3698

Please sign in to comment.