test_futurize.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:packaging 作者: blockstack 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号