REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 5.15 KB
Close
//proc/thread-self/root/opt/cloudlinux/venv/lib/python3.11/site-packages/pyflakes/test/test_dict.py
Text
Base64
""" Tests for dict duplicate keys Pyflakes behavior. """ from pyflakes import messages as m from pyflakes.test.harness import TestCase class Test(TestCase): def test_duplicate_keys(self): self.flakes( "{'yes': 1, 'yes': 2}", m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, ) def test_duplicate_keys_bytes_vs_unicode_py3(self): self.flakes("{b'a': 1, u'a': 2}") def test_duplicate_values_bytes_vs_unicode_py3(self): self.flakes( "{1: b'a', 1: u'a'}", m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, ) def test_multiple_duplicate_keys(self): self.flakes( "{'yes': 1, 'yes': 2, 'no': 2, 'no': 3}", m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, ) def test_duplicate_keys_in_function(self): self.flakes( ''' def f(thing): pass f({'yes': 1, 'yes': 2}) ''', m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, ) def test_duplicate_keys_in_lambda(self): self.flakes( "lambda x: {(0,1): 1, (0,1): 2}", m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, ) def test_duplicate_keys_tuples(self): self.flakes( "{(0,1): 1, (0,1): 2}", m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, ) def test_duplicate_keys_tuples_int_and_float(self): self.flakes( "{(0,1): 1, (0,1.0): 2}", m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, ) def test_duplicate_keys_ints(self): self.flakes( "{1: 1, 1: 2}", m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, ) def test_duplicate_keys_bools(self): self.flakes( "{True: 1, True: 2}", m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, ) def test_duplicate_keys_bools_false(self): # Needed to ensure 2.x correctly coerces these from variables self.flakes( "{False: 1, False: 2}", m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, ) def test_duplicate_keys_none(self): self.flakes( "{None: 1, None: 2}", m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, ) def test_duplicate_variable_keys(self): self.flakes( ''' a = 1 {a: 1, a: 2} ''', m.MultiValueRepeatedKeyVariable, m.MultiValueRepeatedKeyVariable, ) def test_duplicate_variable_values(self): self.flakes( ''' a = 1 b = 2 {1: a, 1: b} ''', m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, ) def test_duplicate_variable_values_same_value(self): # Current behaviour is not to look up variable values. This is to # confirm that. self.flakes( ''' a = 1 b = 1 {1: a, 1: b} ''', m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, ) def test_duplicate_key_float_and_int(self): """ These do look like different values, but when it comes to their use as keys, they compare as equal and so are actually duplicates. The literal dict {1: 1, 1.0: 1} actually becomes {1.0: 1}. """ self.flakes( ''' {1: 1, 1.0: 2} ''', m.MultiValueRepeatedKeyLiteral, m.MultiValueRepeatedKeyLiteral, ) def test_no_duplicate_key_error_same_value(self): self.flakes(''' {'yes': 1, 'yes': 1} ''') def test_no_duplicate_key_errors(self): self.flakes(''' {'yes': 1, 'no': 2} ''') def test_no_duplicate_keys_tuples_same_first_element(self): self.flakes("{(0,1): 1, (0,2): 1}") def test_no_duplicate_key_errors_func_call(self): self.flakes(''' def test(thing): pass test({True: 1, None: 2, False: 1}) ''') def test_no_duplicate_key_errors_bool_or_none(self): self.flakes("{True: 1, None: 2, False: 1}") def test_no_duplicate_key_errors_ints(self): self.flakes(''' {1: 1, 2: 1} ''') def test_no_duplicate_key_errors_vars(self): self.flakes(''' test = 'yes' rest = 'yes' {test: 1, rest: 2} ''') def test_no_duplicate_key_errors_tuples(self): self.flakes(''' {(0,1): 1, (0,2): 1} ''') def test_no_duplicate_key_errors_instance_attributes(self): self.flakes(''' class Test(): pass f = Test() f.a = 1 {f.a: 1, f.a: 1} ''')
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 14
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
__pycache__
DIR
-
drwxr-xr-x
2026-02-06 08:01:08
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
harness.py
1004 B
lrw-r--r--
2026-01-20 13:01:47
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_api.py
26.27 KB
lrw-r--r--
2026-01-20 13:01:47
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_builtin.py
582 B
lrw-r--r--
2026-01-20 13:01:47
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_checker.py
5.78 KB
lrw-r--r--
2026-01-20 13:01:47
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_code_segment.py
4.39 KB
lrw-r--r--
2026-01-20 13:01:47
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_dict.py
5.15 KB
lrw-r--r--
2026-01-20 13:01:47
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_doctests.py
12.55 KB
lrw-r--r--
2026-01-20 13:01:47
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_imports.py
32.91 KB
lrw-r--r--
2026-01-20 13:01:47
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_is_literal.py
4.47 KB
lrw-r--r--
2026-01-20 13:01:47
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_match.py
2.05 KB
lrw-r--r--
2026-01-20 13:01:47
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_other.py
50.48 KB
lrw-r--r--
2026-01-20 13:01:47
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_type_annotations.py
19.83 KB
lrw-r--r--
2026-01-20 13:01:47
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_undefined_names.py
23.01 KB
lrw-r--r--
2026-01-20 13:01:47
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__init__.py
0 B
lrw-r--r--
2026-01-20 13:01:47
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).