fix!: ruff lint errors

* Refactor KanaeDayNight enum
This commit is contained in:
2024-10-01 17:01:03 +08:00
parent e93904bb0d
commit 3b9609ee82
9 changed files with 52 additions and 53 deletions

View File

@ -21,7 +21,8 @@ class TestPlayResultCalculators:
Decimal("-0.00")
) == Decimal("-31.67")
pytest.raises(ValueError, PlayResultCalculators.score_modifier, -1)
with pytest.raises(ValueError, match="negative"):
PlayResultCalculators.score_modifier(-1)
pytest.raises(TypeError, PlayResultCalculators.score_modifier, "9800000")
pytest.raises(TypeError, PlayResultCalculators.score_modifier, None)
@ -38,5 +39,8 @@ class TestPlayResultCalculators:
pytest.raises(TypeError, PlayResultCalculators.play_rating, 10002221, None)
pytest.raises(ValueError, PlayResultCalculators.play_rating, -1, 120)
pytest.raises(ValueError, PlayResultCalculators.play_rating, 10002221, -1)
with pytest.raises(ValueError, match="negative"):
PlayResultCalculators.play_rating(-1, 120)
with pytest.raises(ValueError, match="negative"):
PlayResultCalculators.play_rating(10002221, -1)

View File

@ -14,7 +14,7 @@ def db_conn():
conn.close()
@pytest.fixture()
@pytest.fixture
def db_session(db_conn):
session = Session(bind=db_conn)
yield session

View File

@ -21,7 +21,7 @@ def _difficulty(**kw):
return Difficulty(**defaults)
class Test_Chart:
class TestChart:
def init_db(self, session):
SongsBase.metadata.create_all(session.bind, checkfirst=False)
SongsViewBase.metadata.create_all(session.bind, checkfirst=False)

View File

@ -73,7 +73,9 @@ class TestPlayResultFormatter:
assert PlayResultFormatter.score_grade(5500000) == "D"
assert PlayResultFormatter.score_grade(0) == "D"
pytest.raises(ValueError, PlayResultFormatter.score_grade, -1)
with pytest.raises(ValueError, match="negative"):
PlayResultFormatter.score_grade(-1)
pytest.raises(TypeError, PlayResultFormatter.score_grade, "10001284")
pytest.raises(TypeError, PlayResultFormatter.score_grade, [])
pytest.raises(TypeError, PlayResultFormatter.score_grade, None)
@ -108,7 +110,9 @@ class TestPlayResultFormatter:
assert PlayResultFormatter.clear_type(1) == "NORMAL CLEAR"
assert PlayResultFormatter.clear_type(6) == "UNKNOWN"
pytest.raises(ValueError, PlayResultFormatter.clear_type, -1)
with pytest.raises(ValueError, match="negative"):
PlayResultFormatter.clear_type(-1)
pytest.raises(TypeError, PlayResultFormatter.clear_type, "1")
pytest.raises(TypeError, PlayResultFormatter.clear_type, [])
@ -121,6 +125,8 @@ class TestPlayResultFormatter:
assert PlayResultFormatter.modifier(1) == "EASY"
assert PlayResultFormatter.modifier(6) == "UNKNOWN"
pytest.raises(ValueError, PlayResultFormatter.modifier, -1)
with pytest.raises(ValueError, match="negative"):
PlayResultFormatter.modifier(-1)
pytest.raises(TypeError, PlayResultFormatter.modifier, "1")
pytest.raises(TypeError, PlayResultFormatter.modifier, [])