Commit a9abdb90 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

round_trace: don't trace ndigits if it's the default value

parent 6f0132db
...@@ -18,7 +18,7 @@ class FixRoundTrace(BaseDynamicTraceFix): ...@@ -18,7 +18,7 @@ class FixRoundTrace(BaseDynamicTraceFix):
def _dynamic_trace(number, ndigits=0): def _dynamic_trace(number, ndigits=0):
return ( return (
round(number, ndigits), round(number, ndigits),
(parse_type(type(number)), parse_type(type(ndigits))) (parse_type(type(number)), None if ndigits == 0 else parse_type(type(ndigits)))
) )
# Inspired by https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Lib/lib2to3/fixes/fix_xrange.py#L14 # Inspired by https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Lib/lib2to3/fixes/fix_xrange.py#L14
......
import unittest
from . import FixerTestCase
class testFixRoundTrace(FixerTestCase):
fixer = "round_trace"
def test_single_parameter(self):
b = """round(1.23)"""
a = """round_traced("<string>",1,0,1.23)"""
self.check(b, a)
self.exec_code(a)
self.assertDataEqual("round_modified", [(u'<string>', 1, 0)])
self.assertDataEqual("round_trace", [(u'<string>', 1, 0, u'float', None)])
def test_both_parameters(self):
b = """round(1.23, 4)"""
a = """round_traced("<string>",1,0,1.23, 4)"""
self.check(b, a)
self.exec_code(a)
self.assertDataEqual("round_modified", [(u'<string>', 1, 0)])
self.assertDataEqual("round_trace", [(u'<string>', 1, 0, u'float', u'int')])
if __name__ == '__main__':
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment