Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_with_unit(self):
test = utility.with_unit
self.assertEqual('1px', test((1, 'px')))
self.assertEqual('1px', test(1, 'px'))
self.assertEqual('1.0px', test(1.0, 'px'))
self.assertEqual('0.0px', test('.0', 'px'))
self.assertEqual('0.6px', test(.6, 'px'))
self.assertEqual('1', test(1))
self.assertEqual('1', test(1, None))
self.assertEqual('1', test(1, ))
def increment(self, value, *args):
""" Increment function
args:
value (str): target
returns:
str
"""
n, u = utility.analyze_number(value)
return utility.with_unit(n + 1, u)
def round(self, value, *args):
""" Round number
args:
value (str): target
returns:
str
"""
n, u = utility.analyze_number(value)
return utility.with_unit(
int(utility.away_from_zero_round(float(n))), u)
def decrement(self, value, *args):
""" Decrement function
args:
value (str): target
returns:
str
"""
n, u = utility.analyze_number(value)
return utility.with_unit(n - 1, u)
def percentage(self, value, *args):
""" Return percentage value
args:
value (str): target
returns:
str
"""
n, u = utility.analyze_number(value)
n = int(n * 100.0)
u = '%'
return utility.with_unit(n, u)
def ceil(self, value, *args):
""" Ceil number
args:
value (str): target
returns:
str
"""
n, u = utility.analyze_number(value)
return utility.with_unit(int(math.ceil(n)), u)
def floor(self, value, *args):
""" Floor number
args:
value (str): target
returns:
str
"""
n, u = utility.analyze_number(value)
return utility.with_unit(int(math.floor(n)), u)