Skip to content

Commit

Permalink
Document why packagers mustn't run the test suite.
Browse files Browse the repository at this point in the history
Refs #1509, #1496, #1427, #1426, #1081, #1026, perhaps others.
  • Loading branch information
aaugustin committed Sep 22, 2024
1 parent 44ccee1 commit e44a1ea
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
26 changes: 24 additions & 2 deletions docs/project/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ apologies. I know I can mess up. I can't expect you to tell me, but if you
choose to do so, I'll do my best to handle criticism constructively.
-- Aymeric)*

Contributions
-------------
Contributing
------------

Bug reports, patches and suggestions are welcome!

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

Packaging
---------

Some distributions package websockets so that it can be installed with the
system package manager rather than with pip, possibly in a virtualenv.

If you're packaging websockets for a distribution, you must use `releases
published on PyPI`_ as input. You may check `SLSA attestations on GitHub`_.

.. _releases published on PyPI: https://pypi.org/project/websockets/#files
.. _SLSA attestations on GitHub: https://github.com/python-websockets/websockets/attestations

You mustn't rely on the git repository as input. Specifically, you mustn't
attempt to run the main test suite. It isn't treated as a deliverable of the
project. It doesn't do what you think it does. It's designed for the needs of
developers, not packagers.

On a typical build farm for a distribution, tests that exercise timeouts will
fail randomly. Indeed, the test suite is optimized for running very fast, with a
tolerable level of flakiness, on a high-end laptop without noisy neighbors. This
isn't your context.

Questions
---------

Expand Down
18 changes: 15 additions & 3 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import unittest
import warnings

from websockets.version import released


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


# Unit for timeouts. May be increased on slow machines by setting the
# WEBSOCKETS_TESTS_TIMEOUT_FACTOR environment variable.
MS = 0.001 * float(os.environ.get("WEBSOCKETS_TESTS_TIMEOUT_FACTOR", "1"))
# Unit for timeouts. May be increased in slow or noisy environments by setting
# the WEBSOCKETS_TESTS_TIMEOUT_FACTOR environment variable.

# Downstream distributors insist on running the test suite despites my pleas to
# the contrary. They do it on build farms with unstable performance, leading to
# flakiness, and then they file bugs. Make tests 100x slower to avoid flakiness.

MS = 0.001 * float(
os.environ.get(
"WEBSOCKETS_TESTS_TIMEOUT_FACTOR",
"100" if released else "1",
)
)

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

0 comments on commit e44a1ea

Please sign in to comment.