Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds walrus test and python 3.7/3.8 tox definitions #851

Merged
merged 1 commit into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
13 changes: 13 additions & 0 deletions yapftests/reformatter_basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3033,6 +3033,19 @@ 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()