Skip to content

Commit

Permalink
Skip tests involving f-strings for Python 3.9 (gristlabs#669)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmojaki authored Sep 11, 2023
1 parent 18f7e25 commit 5d7ef23
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions sandbox/grist/test_codebuilder.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
import unittest

import codebuilder
import six
from asttokens.util import fstring_positions_work

import codebuilder
import test_engine

unicode_prefix = 'u' if six.PY2 else ''
Expand Down Expand Up @@ -72,7 +74,7 @@ def test_make_formula_body(self):
self.assertEqual(make_body("'''test1'''\n\"\"\"test2\"\"\""),
"'''test1'''\nreturn \"\"\"test2\"\"\"")

if six.PY3:
if fstring_positions_work():
self.assertEqual(
make_body("f'{$foo + 1 + $bar} 2 {3 + $baz}' + $foo2 + f'{4 + $bar2}!'"),
"return f'{rec.foo + 1 + rec.bar} 2 {3 + rec.baz}' + rec.foo2 + f'{4 + rec.bar2}!'"
Expand Down
2 changes: 2 additions & 0 deletions sandbox/grist/test_formula_prompt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
import six
from asttokens.util import fstring_positions_work

import test_engine
import testutil
Expand Down Expand Up @@ -219,6 +220,7 @@ class Table3:
def reflist(rec: Table3) -> list[Table2]:
''')

@unittest.skipUnless(fstring_positions_work(), "Needs Python 3.10+")
def test_convert_completion(self):
completion = """
Here's some code:
Expand Down
4 changes: 2 additions & 2 deletions sandbox/grist/test_renames.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import unittest

import six
from asttokens.util import fstring_positions_work

import testutil
import test_engine
Expand Down Expand Up @@ -81,7 +81,7 @@ def test_rename_rec_attribute(self):
}]
]})

@unittest.skipUnless(six.PY3, "Python 3 only")
@unittest.skipUnless(fstring_positions_work(), "Python 3.10+ only")
def test_rename_inside_fstring(self):
self.load_sample(self.sample)
self.add_column("People", "CityUpper", formula="f'{$city.upper()}'")
Expand Down

0 comments on commit 5d7ef23

Please sign in to comment.