Skip to content

Commit

Permalink
Fix failing test for latest Ruff version
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Oct 17, 2023
1 parent 7ae72d6 commit 0621462
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,11 @@
print(x)
"""

VERSION_REQUIREMENT_ASTRAL_DOCS = Version("0.0.291")


class TestServer:
maxDiff = None

def test_linting_example(self, ruff_version: Version) -> None:
expected_docs_url = (
"https://docs.astral.sh/ruff/"
if ruff_version >= VERSION_REQUIREMENT_ASTRAL_DOCS
else "https://beta.ruff.rs/docs/"
)

with tempfile.NamedTemporaryFile(suffix=".py") as fp:
fp.write(CONTENTS.encode())
fp.flush()
Expand Down Expand Up @@ -69,11 +61,11 @@ def _handler(params):
{
"code": "F401",
"codeDescription": {
"href": expected_docs_url + "rules/unused-import"
"href": "https://docs.astral.sh/ruff/rules/unused-import"
},
"data": {
"fix": {
"applicability": "Automatic",
"applicability": "safe",
"edits": [
{
"content": "",
Expand All @@ -97,7 +89,7 @@ def _handler(params):
{
"code": "F821",
"codeDescription": {
"href": expected_docs_url + "rules/undefined-name"
"href": "https://docs.astral.sh/ruff/rules/undefined-name"
},
"data": {"fix": None, "noqa_row": 3},
"message": "Undefined name `x`",
Expand All @@ -114,12 +106,6 @@ def _handler(params):
assert expected == actual

def test_no_initialization_options(self, ruff_version: Version) -> None:
expected_docs_url = (
"https://docs.astral.sh/ruff/"
if ruff_version >= VERSION_REQUIREMENT_ASTRAL_DOCS
else "https://beta.ruff.rs/docs/"
)

with tempfile.NamedTemporaryFile(suffix=".py") as fp:
fp.write(CONTENTS.encode())
fp.flush()
Expand Down Expand Up @@ -164,11 +150,11 @@ def _handler(params):
{
"code": "F401",
"codeDescription": {
"href": expected_docs_url + "rules/unused-import"
"href": "https://docs.astral.sh/ruff/rules/unused-import"
},
"data": {
"fix": {
"applicability": "Automatic",
"applicability": "safe",
"edits": [
{
"content": "",
Expand All @@ -192,7 +178,7 @@ def _handler(params):
{
"code": "F821",
"codeDescription": {
"href": expected_docs_url + "rules/undefined-name"
"href": "https://docs.astral.sh/ruff/rules/undefined-name"
},
"data": {"fix": None, "noqa_row": 3},
"message": "Undefined name `x`",
Expand Down

0 comments on commit 0621462

Please sign in to comment.