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_xmlConvertFloat_custom_precision(self):
import ufonormalizer
oldFloatFormat = ufonormalizer.FLOAT_FORMAT
ufonormalizer.FLOAT_FORMAT = "%.3f"
self.assertEqual(xmlConvertFloat(1.001), '1.001')
self.assertEqual(xmlConvertFloat(1.0001), '1')
self.assertEqual(xmlConvertFloat(1.0009), '1.001')
ufonormalizer.FLOAT_FORMAT = "%.0f"
self.assertEqual(xmlConvertFloat(1.001), '1')
self.assertEqual(xmlConvertFloat(1.9), '2')
self.assertEqual(xmlConvertFloat(10.0), '10')
ufonormalizer.FLOAT_FORMAT = oldFloatFormat
def test_xmlConvertFloat_custom_precision(self):
import ufonormalizer
oldFloatFormat = ufonormalizer.FLOAT_FORMAT
ufonormalizer.FLOAT_FORMAT = "%.3f"
self.assertEqual(xmlConvertFloat(1.001), '1.001')
self.assertEqual(xmlConvertFloat(1.0001), '1')
self.assertEqual(xmlConvertFloat(1.0009), '1.001')
ufonormalizer.FLOAT_FORMAT = "%.0f"
self.assertEqual(xmlConvertFloat(1.001), '1')
self.assertEqual(xmlConvertFloat(1.9), '2')
self.assertEqual(xmlConvertFloat(10.0), '10')
ufonormalizer.FLOAT_FORMAT = oldFloatFormat
def test_xmlConvertFloat_no_rounding(self):
import ufonormalizer
oldFloatFormat = ufonormalizer.FLOAT_FORMAT
ufonormalizer.FLOAT_FORMAT = None
self.assertEqual(xmlConvertFloat(1.0000000000000002), '1.0000000000000002')
self.assertEqual(xmlConvertFloat(1.00000000000000001), '1')
self.assertEqual(xmlConvertFloat(1.00000000000000019), '1.0000000000000002')
self.assertEqual(xmlConvertFloat(1e-16), '0.0000000000000001')
self.assertEqual(xmlConvertFloat(1e-17), '0')
ufonormalizer.FLOAT_FORMAT = oldFloatFormat
def test_xmlConvertFloat_custom_precision(self):
import ufonormalizer
oldFloatFormat = ufonormalizer.FLOAT_FORMAT
ufonormalizer.FLOAT_FORMAT = "%.3f"
self.assertEqual(xmlConvertFloat(1.001), '1.001')
self.assertEqual(xmlConvertFloat(1.0001), '1')
self.assertEqual(xmlConvertFloat(1.0009), '1.001')
ufonormalizer.FLOAT_FORMAT = "%.0f"
self.assertEqual(xmlConvertFloat(1.001), '1')
self.assertEqual(xmlConvertFloat(1.9), '2')
self.assertEqual(xmlConvertFloat(10.0), '10')
ufonormalizer.FLOAT_FORMAT = oldFloatFormat
def test_xmlConvertFloat_no_rounding(self):
import ufonormalizer
oldFloatFormat = ufonormalizer.FLOAT_FORMAT
ufonormalizer.FLOAT_FORMAT = None
self.assertEqual(xmlConvertFloat(1.0000000000000002), '1.0000000000000002')
self.assertEqual(xmlConvertFloat(1.00000000000000001), '1')
self.assertEqual(xmlConvertFloat(1.00000000000000019), '1.0000000000000002')
self.assertEqual(xmlConvertFloat(1e-16), '0.0000000000000001')
self.assertEqual(xmlConvertFloat(1e-17), '0')
ufonormalizer.FLOAT_FORMAT = oldFloatFormat
def test_xmlConvertFloat_no_rounding(self):
import ufonormalizer
oldFloatFormat = ufonormalizer.FLOAT_FORMAT
ufonormalizer.FLOAT_FORMAT = None
self.assertEqual(xmlConvertFloat(1.0000000000000002), '1.0000000000000002')
self.assertEqual(xmlConvertFloat(1.00000000000000001), '1')
self.assertEqual(xmlConvertFloat(1.00000000000000019), '1.0000000000000002')
self.assertEqual(xmlConvertFloat(1e-16), '0.0000000000000001')
self.assertEqual(xmlConvertFloat(1e-17), '0')
ufonormalizer.FLOAT_FORMAT = oldFloatFormat
def test_xmlConvertFloat_custom_precision(self):
import ufonormalizer
oldFloatFormat = ufonormalizer.FLOAT_FORMAT
ufonormalizer.FLOAT_FORMAT = "%.3f"
self.assertEqual(xmlConvertFloat(1.001), '1.001')
self.assertEqual(xmlConvertFloat(1.0001), '1')
self.assertEqual(xmlConvertFloat(1.0009), '1.001')
ufonormalizer.FLOAT_FORMAT = "%.0f"
self.assertEqual(xmlConvertFloat(1.001), '1')
self.assertEqual(xmlConvertFloat(1.9), '2')
self.assertEqual(xmlConvertFloat(10.0), '10')
ufonormalizer.FLOAT_FORMAT = oldFloatFormat
def test_xmlConvertFloat_custom_precision(self):
import ufonormalizer
oldFloatFormat = ufonormalizer.FLOAT_FORMAT
ufonormalizer.FLOAT_FORMAT = "%.3f"
self.assertEqual(xmlConvertFloat(1.001), '1.001')
self.assertEqual(xmlConvertFloat(1.0001), '1')
self.assertEqual(xmlConvertFloat(1.0009), '1.001')
ufonormalizer.FLOAT_FORMAT = "%.0f"
self.assertEqual(xmlConvertFloat(1.001), '1')
self.assertEqual(xmlConvertFloat(1.9), '2')
self.assertEqual(xmlConvertFloat(10.0), '10')
ufonormalizer.FLOAT_FORMAT = oldFloatFormat
def test_xmlConvertFloat_custom_precision(self):
import ufonormalizer
oldFloatFormat = ufonormalizer.FLOAT_FORMAT
ufonormalizer.FLOAT_FORMAT = "%.3f"
self.assertEqual(xmlConvertFloat(1.001), '1.001')
self.assertEqual(xmlConvertFloat(1.0001), '1')
self.assertEqual(xmlConvertFloat(1.0009), '1.001')
ufonormalizer.FLOAT_FORMAT = "%.0f"
self.assertEqual(xmlConvertFloat(1.001), '1')
self.assertEqual(xmlConvertFloat(1.9), '2')
self.assertEqual(xmlConvertFloat(10.0), '10')
ufonormalizer.FLOAT_FORMAT = oldFloatFormat
def test_xmlConvertFloat_custom_precision(self):
import ufonormalizer
oldFloatFormat = ufonormalizer.FLOAT_FORMAT
ufonormalizer.FLOAT_FORMAT = "%.3f"
self.assertEqual(xmlConvertFloat(1.001), '1.001')
self.assertEqual(xmlConvertFloat(1.0001), '1')
self.assertEqual(xmlConvertFloat(1.0009), '1.001')
ufonormalizer.FLOAT_FORMAT = "%.0f"
self.assertEqual(xmlConvertFloat(1.001), '1')
self.assertEqual(xmlConvertFloat(1.9), '2')
self.assertEqual(xmlConvertFloat(10.0), '10')
ufonormalizer.FLOAT_FORMAT = oldFloatFormat