dask / dask/distributed

test_bad_local_directory fails if run with root permissions on Linux.

Open
#5,404 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.7k
Forks
778
Avg merge
2h 50m
Merged PRs (30d)
3

Description

**What happened**:

Under some test running conditions on at least Debian, test_bad_local_directory fails, because the test assumes that it shouldn't have write permissions to /, but if you're running as root. you can write to /.

**What you expected to happen**:

It would be nice if the test didn't generate an error when run as root.

**Anything else we need to know?**:

**Environment**:

- Dask version: 2021.08.1, 2021.09.1
- Python version: 3.9.2
- Operating System: Debian bookworm
- Install method (conda, pip, source): Debian package.

So what do you think of this patch (against 2021.09.1) as an alternate solution? I think it would also handle Windows more cleanly than the current try/except/else.

```
--- a/distributed/tests/test_worker.py
+++ b/distributed/tests/test_worker.py
@@ -1730,6 +1730,8 @@
assert "Heartbeat to scheduler failed" in logger.getvalue()


+@pytest.mark.skipif(not os.access("/", os.W_OK),
+ reason="skip if we have elevated privileges")
@gen_cluster(nthreads=[])
async def test_bad_local_directory(s):
try:
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.