Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the tests really run, and fix test failures #78

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[test]
python -m pip install .[test,whoosh]

- name: Test with pytest
run: python -m pytest -vv --durations 25
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ enable_error_code = [

[[tool.mypy.overrides]]
module = [
"pytest",
"sqlalchemy",
"sqlalchemy.orm",
"sqlalchemy.sql",
"sqlalchemy.sql.expression",
"whoosh",
"whoosh.analysis",
"whoosh.fields",
Expand Down
7 changes: 4 additions & 3 deletions sphinxcontrib/websupport/storage/sqlalchemy_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

from __future__ import annotations

from datetime import datetime, timezone
from datetime import datetime

from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String, Text
from sqlalchemy.orm import aliased, declarative_base, relationship, sessionmaker
from sqlalchemy.sql.expression import true

Base = declarative_base()
Session = sessionmaker()
Expand Down Expand Up @@ -51,7 +52,7 @@ def nested_comments(self, username, moderator):

# Filter out all comments that are not moderated yet.
if not moderator:
q = q.filter(Comment.displayed is True)
q = q.filter(Comment.displayed == true())

# Retrieve all results. Results must be ordered by Comment.path
# so that we can easily transform them from a flat list to a tree.
Expand Down Expand Up @@ -159,7 +160,7 @@ def serializable(self, vote=0):
"""Creates a serializable representation of the comment. This is
converted to JSON, and used on the client side.
"""
delta = datetime.now(tz=timezone.utc) - self.time
delta = datetime.now() - self.time # noqa: DTZ005

time = {
"year": self.time.year,
Expand Down
4 changes: 2 additions & 2 deletions sphinxcontrib/websupport/storage/sqlalchemystorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from datetime import datetime, timezone
from datetime import datetime

import sqlalchemy
from sqlalchemy.orm import aliased
Expand Down Expand Up @@ -72,7 +72,7 @@ def add_comment(self, text, displayed, username, time,
raise CommentNotAllowedError(msg)

comment = Comment(text, displayed, username, 0,
time or datetime.now(tz=timezone.utc), proposal, proposal_diff)
time or datetime.now(), proposal, proposal_diff) # noqa: DTZ005
session.add(comment)
session.flush()
# We have to flush the session before setting the path so the
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
)


@pytest.fixture(scope='session')
@pytest.fixture(scope='session') # type: ignore[misc]
def rootdir() -> Path:
return Path(__file__).resolve().parent / 'roots'