4
4
Conformance and testing
5
5
=======================
6
6
7
- Much of the behavior of webcolors is dictated by the relevant web standards,
8
- which define the acceptable color formats, how to determine valid values for
9
- each format and the values corresponding to defined color names. Maintaining
10
- correct conversions and conformance to those standards is crucial.
7
+ Much of the behavior of ``webcolors `` is dictated by the relevant web
8
+ standards, which define the acceptable color formats, how to determine valid
9
+ values for each format and the values corresponding to defined color
10
+ names. Maintaining correct conversions and conformance to those standards is
11
+ crucial.
11
12
12
- The source distribution of webcolors (the ``.tar.gz `` file you can download
13
+ The source distribution of `` webcolors `` (the ``.tar.gz `` file you can download
13
14
from the Python Package Index) includes a ``tests/ `` directory containing a
14
15
normal test suite as well as supplemental test files which perform more
15
16
comprehensive verification.
@@ -18,8 +19,8 @@ comprehensive verification.
18
19
The normal test suite
19
20
---------------------
20
21
21
- The normal test suite for webcolors aims for 100% coverage of code paths, but
22
- does *not * aim for 100% coverage of possible color value inputs and
22
+ The normal test suite for `` webcolors `` aims for 100% coverage of code paths,
23
+ but does *not * aim for 100% coverage of possible color value inputs and
23
24
outputs. Instead, it uses a small number of test values to routinely exercise
24
25
various functions.
25
26
@@ -51,9 +52,9 @@ the results of test runs online `at GitHub
51
52
<https://github.com/ubernostrum/webcolors/actions/workflows/ci.yml/> `_.
52
53
53
54
However, the normal test suite cannot guarantee that the color definitions
54
- included in webcolors correspond to those in the relevant standards, and cannot
55
- provide guarantees of correct conversions for all possible values. For that,
56
- additional tests are required.
55
+ included in `` webcolors `` correspond to those in the relevant standards, and
56
+ cannot provide guarantees of correct conversions for all possible values. For
57
+ that, additional tests are required.
57
58
58
59
59
60
.. _full-verification :
@@ -64,16 +65,16 @@ Full verification tests
64
65
These tests are contained in two files which are not executed during normal
65
66
test runs: ``tests/definitions.py `` and ``tests/full_colors.py ``. They are not
66
67
run as part of the normal test suite, but are run prior to each release of
67
- webcolors.
68
+ `` webcolors `` .
68
69
69
70
70
71
Verifying color definitions
71
72
~~~~~~~~~~~~~~~~~~~~~~~~~~~
72
73
73
74
The ``definitions.py `` test file verifies that the color definitions in
74
- webcolors are correct. It does this by downloading the relevant standards
75
+ `` webcolors `` are correct. It does this by downloading the relevant standards
75
76
documents as HTML, parsing out the color definitions in them, and comparing
76
- them to the definitions in webcolors. That consists of:
77
+ them to the definitions in `` webcolors `` . That consists of:
77
78
78
79
* Parsing out the names and hexadecimal values of the 16 named colors in the
79
80
HTML 4 standard, and checking that the names and values in
@@ -102,7 +103,7 @@ For conversions between hexadecimal and integer ``rgb()``, it generates all
102
103
16,777,216 possible color values for each format in order (starting at
103
104
``#000000 `` and ``(0,0,0) `` and incrementing), and verifies that each one
104
105
converts to the corresponding value in the other format. Thus, it is possible
105
- to be confident that webcolors provides correct conversions between all
106
+ to be confident that `` webcolors `` provides correct conversions between all
106
107
possible color values in those formats.
107
108
108
109
Testing the correctness of conversion to and from percentage ``rgb() ``,
@@ -124,7 +125,7 @@ however, is more difficult, and a full test is not provided, for two reasons:
124
125
uncountably infinite, testing all legal values is not possible on current
125
126
hardware in any reasonable amount of time.
126
127
127
- Since precise correctness and completeness are not achievable, webcolors
128
+ Since precise correctness and completeness are not achievable, `` webcolors ``
128
129
instead aims to achieve *consistency * in conversions. Specifically, the
129
130
``full_colors.py `` test generates all 16,777,216 integer ``rgb() `` triplets,
130
131
and for each such triplet `t ` verifies that the following assertion holds:
@@ -137,11 +138,11 @@ and for each such triplet `t` verifies that the following assertion holds:
137
138
Running the tests
138
139
-----------------
139
140
140
- The standard test runner for webcolors is `nox <https://nox.thea.codes/ >`_,
141
+ The standard test runner for `` webcolors `` is `nox <https://nox.thea.codes/ >`_,
141
142
which supports testing against multiple Python versions and executing a variety
142
- of different test tasks. The source distribution of webcolors includes its
143
+ of different test tasks. The source distribution of `` webcolors `` includes its
143
144
``noxfile.py `` file. To run the tests, install nox (``pip install nox ``), then
144
- download and unpack a git checkout or source package of webcolors.
145
+ download and unpack a git checkout or source package of `` webcolors `` .
145
146
146
147
To run the normal test suite against the complete set of supported Python
147
148
versions:
@@ -160,8 +161,8 @@ versions:
160
161
py -m pip install nox
161
162
py -m nox
162
163
163
- This requires that you have each supported version of Python (for webcolors
164
- |release |, this is 3.7 , 3.8 , 3.9 , 3.10 , and 3.11 ) available. To test only
164
+ This requires that you have each supported version of Python (for `` webcolors ``
165
+ |release |, this is 3.8 , 3.9 , 3.10 , 3.11 , and 3.12 ) available. To test only
165
166
against a specific version of Python, use the ``--python `` flag and pass the
166
167
version to test. For example, to test on Python 3.10:
167
168
@@ -178,8 +179,8 @@ version to test. For example, to test on Python 3.10:
178
179
py -m nox --python " 3.10"
179
180
180
181
To run the full verification tests for definition correctness and conversions,
181
- specify the "release" test keyword instead (so named because these tests
182
- are usually run only prior to a new release of webcolors):
182
+ specify the "release" test keyword instead (so named because these tests are
183
+ usually run only prior to a new release of `` webcolors `` ):
183
184
184
185
.. tab :: macOS/Linux/other Unix
185
186
0 commit comments