def test_safe_division(self):
"""
Tests whether Py2 scripts using old-style division still work
after futurization.
"""
before = """
x = 3 / 2
y = 3. / 2
assert x == 1 and isinstance(x, int)
assert y == 1.5 and isinstance(y, float)
"""
after = """
from __future__ import division
from past.utils import old_div
x = old_div(3, 2)
y = old_div(3., 2)
assert x == 1 and isinstance(x, int)
assert y == 1.5 and isinstance(y, float)
"""
self.convert_check(before, after)
评论列表
文章目录