Skip to content

Commit

Permalink
Remove the type validation system in status responses
Browse files Browse the repository at this point in the history
  • Loading branch information
PerchunPak committed Apr 16, 2023
1 parent 16c4c18 commit abd97e4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
2 changes: 1 addition & 1 deletion mcstatus/pinger.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def read_status(self) -> JavaStatusResponse:
raise IOError("Received invalid JSON")
try:
return JavaStatusResponse.build(raw, latency=(received - start) * 1000)
except (ValueError, TypeError) as e:
except KeyError as e:
raise IOError(f"Received invalid status response: {e}")

def test_ping(self) -> float:
Expand Down
14 changes: 0 additions & 14 deletions tests/status_response/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import abc
from typing import Any, TypeVar, cast

import pytest

from mcstatus.status_response import BaseStatusResponse

__all__ = ["BaseStatusResponseTest"]
Expand Down Expand Up @@ -74,18 +72,6 @@ def test_optional_field_turns_into_none(self, build: BaseStatusResponse, to_remo
del raw[to_remove]
assert getattr(type(build).build(raw), attribute_name) is None

def test_value_validating(self, build: BaseStatusResponse, exclude_field: str) -> None:
raw = cast(list, self.BUILD_METHOD_VALIDATION)[2].copy()
raw.pop(exclude_field)
with pytest.raises(ValueError):
type(build).build(raw)

def test_type_validating(self, build: BaseStatusResponse, to_change_field: str) -> None:
raw = cast(list, self.BUILD_METHOD_VALIDATION)[2].copy()
raw[to_change_field] = object()
with pytest.raises(TypeError):
type(build).build(raw)

def _dependency_table(self) -> dict[str, bool]:
# a key in the dict must be a name of a test implementation.
# and a value of the dict is a bool. if it's false - we
Expand Down

0 comments on commit abd97e4

Please sign in to comment.