Skip to content

port test_local.LocalTest to pytest tests to allow use of loop fixture #6523

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

Merged
merged 2 commits into from
Jun 10, 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
48 changes: 43 additions & 5 deletions distributed/deploy/tests/test_local.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import asyncio
import subprocess
import sys
import unittest
from threading import Lock
from time import sleep
from urllib.parse import urlparse
Expand All @@ -15,7 +14,6 @@
from distributed import Client, LocalCluster, Nanny, Worker, get_client
from distributed.compatibility import LINUX
from distributed.core import Status
from distributed.deploy.utils_test import ClusterTest
from distributed.metrics import time
from distributed.system import MEMORY_LIMIT
from distributed.utils import TimeoutError, sync
Expand Down Expand Up @@ -170,9 +168,49 @@ def test_transports_tcp_port():
assert e.submit(inc, 4).result() == 5


class LocalTest(ClusterTest, unittest.TestCase):
Cluster = LocalCluster # type: ignore
kwargs = {"silence_logs": False, "dashboard_address": ":0", "processes": False}
def test_cores(loop):
with LocalCluster(
n_workers=2,
scheduler_port=0,
silence_logs=False,
dashboard_address=":0",
processes=False,
loop=loop,
) as cluster, Client(cluster.scheduler_address, loop=loop) as client:
client.scheduler_info()
assert len(client.nthreads()) == 2


def test_submit(loop):
with LocalCluster(
n_workers=2,
scheduler_port=0,
silence_logs=False,
dashboard_address=":0",
processes=False,
loop=loop,
) as cluster, Client(cluster.scheduler_address, loop=loop) as client:
future = client.submit(lambda x: x + 1, 1)
assert future.result() == 2


def test_context_manager(loop):
with LocalCluster(
silence_logs=False, dashboard_address=":0", processes=False, loop=loop
) as c, Client(c) as e:
assert e.nthreads()


def test_no_workers_sync(loop):
with LocalCluster(
n_workers=0,
scheduler_port=0,
silence_logs=False,
dashboard_address=":0",
processes=False,
loop=loop,
):
pass


def test_Client_with_local(loop):
Expand Down
38 changes: 0 additions & 38 deletions distributed/deploy/utils_test.py

This file was deleted.