Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address review: move test_guido_as_bdfl_ineq_tokens()
  • Loading branch information
skirpichev committed Aug 11, 2026
commit 9ea138fced4c4a95d908c059dbd9481f518514ca
25 changes: 0 additions & 25 deletions Lib/test/test_flufl.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,6 @@ def test_barry_as_bdfl_relative_import(self):
self.assertEqual(cm.exception.lineno, 1)
self.assertEqual(cm.exception.offset, len(code) - 4)

def test_guido_as_bdfl_ineq_tokens(self):
code = """
from io import BytesIO
import tokenize
from test.test_tokenize import stringify_tokens_from_source

s = "{0}"
f = BytesIO(s.encode('utf-8'))
globals()['result'] = stringify_tokens_from_source(tokenize.tokenize(f.readline), s)
"""
ns = {}
exec(code.format('1 != 2'), ns)
self.assertEqual(ns['result'],
[" ENCODING 'utf-8' (0, 0) (0, 0)",
" NUMBER '1' (1, 0) (1, 1)",
" OP '!=' (1, 2) (1, 4)",
" NUMBER '2' (1, 5) (1, 6)"])
exec(code.format('1 <> 2'), ns)
self.assertEqual(ns['result'],
[" ENCODING 'utf-8' (0, 0) (0, 0)",
" NUMBER '1' (1, 0) (1, 1)",
" OP '<' (1, 2) (1, 3)",
" OP '>' (1, 3) (1, 4)",
" NUMBER '2' (1, 5) (1, 6)"])


if __name__ == '__main__':
unittest.main()
14 changes: 14 additions & 0 deletions Lib/test/test_tokenize.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,20 @@ def test_multiline_non_ascii_fstring_with_expr(self):
FSTRING_END \'"\' (2, 2) (2, 3)
""")

def test_ineq_tokens(self):
self.check_tokenize("1 != 2", """\
NUMBER '1' (1, 0) (1, 1)
OP '!=' (1, 2) (1, 4)
NUMBER '2' (1, 5) (1, 6)
""")
self.check_tokenize("1 <> 2", """\
NUMBER '1' (1, 0) (1, 1)
OP '<' (1, 2) (1, 3)
OP '>' (1, 3) (1, 4)
NUMBER '2' (1, 5) (1, 6)
""")


class GenerateTokensTest(TokenizeTest):
def check_tokenize(self, s, expected):
# Format the tokens in s in a table format.
Expand Down