summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_compile.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index b81d847..f7ef7a1 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -1,6 +1,7 @@
import contextlib
import dis
import io
+import itertools
import math
import opcode
import os
@@ -2687,6 +2688,22 @@ class TestInstructionSequence(unittest.TestCase):
self.compare_instructions(seq, [('LOAD_CONST', 1, 1, 0, 0, 0)])
self.compare_instructions(seq.get_nested()[0], [('LOAD_CONST', 2, 2, 0, 0, 0)])
+ def test_static_attributes_are_sorted(self):
+ code = (
+ 'class T:\n'
+ ' def __init__(self):\n'
+ ' self.{V1} = 10\n'
+ ' self.{V2} = 10\n'
+ ' def foo(self):\n'
+ ' self.{V3} = 10\n'
+ )
+ attributes = ("a", "b", "c")
+ for perm in itertools.permutations(attributes):
+ var_names = {f'V{i + 1}': name for i, name in enumerate(perm)}
+ ns = run_code(code.format(**var_names))
+ t = ns['T']
+ self.assertEqual(t.__static_attributes__, attributes)
+
if __name__ == "__main__":
unittest.main()