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

Fix multiple issues in tests #358

Merged
merged 2 commits into from
Aug 15, 2022
Merged
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 pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ mcstatus = 'mcstatus.__main__:cli'
[tool.pytest.ini_options]
minversion = "6.0"
addopts = "--strict-markers --doctest-modules --cov=mcstatus --cov-append --cov-branch --cov-report=term-missing -vvv --no-cov-on-fail --asyncio-mode=strict"
testpaths = ["mcstatus/tests"]
testpaths = ["tests"]

[tool.poetry-dynamic-versioning]
bump = true
Expand Down
File renamed without changes.
Empty file added tests/protocol/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def test_write_buffer(self):
assert self.connection.flush() == bytearray.fromhex("027FAA")


class TCPSocketConnectionTest:
class TestTCPSocketConnection:
def setup_method(self):
self.test_addr = Address("localhost", 1234)

Expand Down Expand Up @@ -245,7 +245,7 @@ def test_write(self):
self.connection.socket.send.assert_called_once_with(bytearray.fromhex("7FAA")) # type: ignore[attr-defined]


class UDPSocketConnectionTest:
class TestUDPSocketConnection:
def setup_method(self):
self.test_addr = Address("localhost", 1234)

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from mcstatus.protocol.connection import Connection
from mcstatus.querier import AsyncServerQuerier
from mcstatus.tests.test_async_pinger import async_decorator
from tests.test_async_pinger import async_decorator


class FakeUDPAsyncConnection(Connection):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from mcstatus.tests.test_async_pinger import async_decorator
from mcstatus.utils import retry
from tests.test_async_pinger import async_decorator


def test_sync_success():
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions mcstatus/tests/test_timeout.py → tests/test_timeout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import typing
from unittest.mock import patch

import pytest
Expand All @@ -8,9 +9,9 @@


class FakeAsyncStream(asyncio.StreamReader):
async def read(self, n: int) -> bytes:
await asyncio.sleep(delay=2)
return bytes([0] * n)
async def read(self, *args, **kwargs) -> typing.NoReturn:
await asyncio.sleep(2)
raise NotImplementedError("tests are designed to timeout before reaching this line")


async def fake_asyncio_asyncio_open_connection(hostname: str, port: int):
Expand Down
14 changes: 7 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ commands =

[testenv:format]
commands =
black ./mcstatus
isort ./mcstatus
black .
isort .

[testenv:format-check]
commands =
black --check ./mcstatus
isort --check ./mcstatus
black --check .
isort --check .

[testenv:lint]
passenv = HOME
commands =
pyright ./mcstatus
flake8 ./mcstatus
pyright .
flake8 .

[testenv:coverage]
depends =
Expand All @@ -39,4 +39,4 @@ setenv =
COVERAGE_FILE=.coverage
commands =
coverage combine
coverage report --show-missing --fail-under=80
coverage report --show-missing --fail-under=70