aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2019-02-19 17:24:49 -0500
committerJason R. Coombs <jaraco@jaraco.com>2019-02-19 17:27:16 -0500
commit78996f70807b9e0e50bc68c7579b339fedb7cade (patch)
treefeb83842a9ed2d5efdb700f817736fb31aedcfc7
parent4a6b8ba7ced6bb841000a59bdef7f9879fb6578d (diff)
downloadexternal_python_setuptools-78996f70807b9e0e50bc68c7579b339fedb7cade.tar.gz
external_python_setuptools-78996f70807b9e0e50bc68c7579b339fedb7cade.tar.bz2
external_python_setuptools-78996f70807b9e0e50bc68c7579b339fedb7cade.zip
Expand tests to capture legacy behavior (sorted keys on older Pythons) and new behavior (honor author's order on Python 3.6)
-rw-r--r--setuptools/tests/test_dist.py50
1 files changed, 45 insertions, 5 deletions
diff --git a/setuptools/tests/test_dist.py b/setuptools/tests/test_dist.py
index e349d068..7409400f 100644
--- a/setuptools/tests/test_dist.py
+++ b/setuptools/tests/test_dist.py
@@ -265,14 +265,54 @@ def test_maintainer_author(name, attrs, tmpdir):
assert line in pkg_lines_set
-def test_provides_extras_deterministic_order():
+def test_extras_deterministic_order():
+ """
+ On all Pythons, if extras are indicated in sorted order, they will
+ be presented in that order.
+ """
attrs = dict(extras_require=dict(
a=['foo'],
b=['bar'],
))
dist = Distribution(attrs)
- assert dist.metadata.provides_extras == ['a', 'b']
- attrs['extras_require'] = dict(
- reversed(list(attrs['extras_require'].items())))
+ assert (
+ dist.metadata.provides_extras ==
+ list(dist.extras_require.keys()) ==
+ ['a', 'b']
+ )
+
+
+@pytest.mark.skipif('sys.version_info < (3, 6)')
+def test_extras_deterministic_order_reversed():
+ """
+ On newer Pythons, honor the order of the extras_require keys
+ as indicated by the author.
+ """
+ attrs = dict(extras_require=dict(
+ b=['bar'],
+ a=['foo'],
+ ))
+ dist = Distribution(attrs)
+ assert (
+ dist.metadata.provides_extras ==
+ list(dist.extras_require.keys()) ==
+ ['b', 'a']
+ )
+
+
+@pytest.mark.skipif('sys.version_info > (3, 6)')
+def test_extras_deterministic_order_reversed_legacy():
+ """
+ On older Pythons, dict order is non-deterministic, so enforce order
+ of keys.
+ """
+ attrs = dict(extras_require=dict(
+ b=['bar'],
+ a=['foo'],
+ ))
dist = Distribution(attrs)
- assert dist.metadata.provides_extras == ['b', 'a']
+ assert (
+ dist.metadata.provides_extras ==
+ list(dist.extras_require.keys()) ==
+ ['a', 'b']
+ )