Skip to content

Commit 1b2cfb7

Browse files
[3.13] pythongh-130193: Increase test coverage of gettext.c2py (pythonGH-130208) (pythonGH-130217)
(cherry picked from commit fb2d325) Co-authored-by: Tomas R <[email protected]>
1 parent 8f33c7a commit 1b2cfb7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Lib/test/test_gettext.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,12 +567,18 @@ def test_decimal_number(self):
567567
def test_invalid_syntax(self):
568568
invalid_expressions = [
569569
'x>1', '(n>1', 'n>1)', '42**42**42', '0xa', '1.0', '1e2',
570-
'n>0x1', '+n', '-n', 'n()', 'n(1)', '1+', 'nn', 'n n',
570+
'n>0x1', '+n', '-n', 'n()', 'n(1)', '1+', 'nn', 'n n', 'n ? 1 2'
571571
]
572572
for expr in invalid_expressions:
573573
with self.assertRaises(ValueError):
574574
gettext.c2py(expr)
575575

576+
def test_negation(self):
577+
f = gettext.c2py('!!!n')
578+
self.assertEqual(f(0), 1)
579+
self.assertEqual(f(1), 0)
580+
self.assertEqual(f(2), 0)
581+
576582
def test_nested_condition_operator(self):
577583
self.assertEqual(gettext.c2py('n?1?2:3:4')(0), 4)
578584
self.assertEqual(gettext.c2py('n?1?2:3:4')(1), 2)

0 commit comments

Comments
 (0)