Skip to content

Commit e44a1ea

Browse files
committed
Document why packagers mustn't run the test suite.
Refs #1509, #1496, #1427, #1426, #1081, #1026, perhaps others.
1 parent 44ccee1 commit e44a1ea

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

docs/project/contributing.rst

+24-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ apologies. I know I can mess up. I can't expect you to tell me, but if you
1717
choose to do so, I'll do my best to handle criticism constructively.
1818
-- Aymeric)*
1919

20-
Contributions
21-
-------------
20+
Contributing
21+
------------
2222

2323
Bug reports, patches and suggestions are welcome!
2424

@@ -34,6 +34,28 @@ websockets.
3434
.. _issue: https://github.com/python-websockets/websockets/issues/new
3535
.. _pull request: https://github.com/python-websockets/websockets/compare/
3636

37+
Packaging
38+
---------
39+
40+
Some distributions package websockets so that it can be installed with the
41+
system package manager rather than with pip, possibly in a virtualenv.
42+
43+
If you're packaging websockets for a distribution, you must use `releases
44+
published on PyPI`_ as input. You may check `SLSA attestations on GitHub`_.
45+
46+
.. _releases published on PyPI: https://pypi.org/project/websockets/#files
47+
.. _SLSA attestations on GitHub: https://github.com/python-websockets/websockets/attestations
48+
49+
You mustn't rely on the git repository as input. Specifically, you mustn't
50+
attempt to run the main test suite. It isn't treated as a deliverable of the
51+
project. It doesn't do what you think it does. It's designed for the needs of
52+
developers, not packagers.
53+
54+
On a typical build farm for a distribution, tests that exercise timeouts will
55+
fail randomly. Indeed, the test suite is optimized for running very fast, with a
56+
tolerable level of flakiness, on a high-end laptop without noisy neighbors. This
57+
isn't your context.
58+
3759
Questions
3860
---------
3961

tests/utils.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import unittest
1010
import warnings
1111

12+
from websockets.version import released
13+
1214

1315
# Generate TLS certificate with:
1416
# $ openssl req -x509 -config test_localhost.cnf -days 15340 -newkey rsa:2048 \
@@ -39,9 +41,19 @@
3941
DATE = email.utils.formatdate(usegmt=True)
4042

4143

42-
# Unit for timeouts. May be increased on slow machines by setting the
43-
# WEBSOCKETS_TESTS_TIMEOUT_FACTOR environment variable.
44-
MS = 0.001 * float(os.environ.get("WEBSOCKETS_TESTS_TIMEOUT_FACTOR", "1"))
44+
# Unit for timeouts. May be increased in slow or noisy environments by setting
45+
# the WEBSOCKETS_TESTS_TIMEOUT_FACTOR environment variable.
46+
47+
# Downstream distributors insist on running the test suite despites my pleas to
48+
# the contrary. They do it on build farms with unstable performance, leading to
49+
# flakiness, and then they file bugs. Make tests 100x slower to avoid flakiness.
50+
51+
MS = 0.001 * float(
52+
os.environ.get(
53+
"WEBSOCKETS_TESTS_TIMEOUT_FACTOR",
54+
"100" if released else "1",
55+
)
56+
)
4557

4658
# PyPy, asyncio's debug mode, and coverage penalize performance of this
4759
# test suite. Increase timeouts to reduce the risk of spurious failures.

0 commit comments

Comments
 (0)