Skip to content

Commit

Permalink
Adds walrus test and python 3.7/3.8 tox definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmego committed Aug 4, 2020
1 parent 51ffe2d commit 55274a2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist=py27,py34,py35,py36
envlist=py27,py34,py35,py36,py37,py38

[testenv]
commands=
Expand Down
2 changes: 2 additions & 0 deletions yapf/yapflib/py3compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

PY3 = sys.version_info[0] >= 3
PY36 = sys.version_info[0] >= 3 and sys.version_info[1] >= 6
PY37 = sys.version_info[0] >= 3 and sys.version_info[1] >= 7
PY38 = sys.version_info[0] >= 3 and sys.version_info[1] >= 8

if PY3:
StringIO = io.StringIO
Expand Down
14 changes: 14 additions & 0 deletions yapftests/reformatter_basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3033,6 +3033,20 @@ def testForceMultilineDict_False(self):
finally:
style.SetGlobalStyle(style.CreateYapfStyle())

@unittest.skipUnless(py3compat.PY38, 'Requires Python 3.8')
def testWalrus(self):
unformatted_code = textwrap.dedent("""\
if (x := len([1]*1000)>100):
print(f'{x} is pretty big' )
""")
expected = textwrap.dedent("""\
if (x := len([1] * 1000) > 100):
print(f'{x} is pretty big')
""")
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected,
reformatter.Reformat(uwlines))


if __name__ == '__main__':
unittest.main()

0 comments on commit 55274a2

Please sign in to comment.