def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.decimal_places = 3 self.prefix_keys = prefix_map.copy() self.units = 'U' self._value = None
from ddt import ddt, data from decimal import Decimal from qtrf.numeric_suffix import prefix_map, to_decimal, to_str import unittest # frequency prefixes frequency_prefix_map = prefix_map.copy() del(frequency_prefix_map['f']) del(frequency_prefix_map['p']) del(frequency_prefix_map['n']) del(frequency_prefix_map['m']) # farads prefixes farads_prefix_map = prefix_map.copy() del(farads_prefix_map['K']) del(farads_prefix_map['M']) del(farads_prefix_map['G']) del(farads_prefix_map['T']) @ddt class TestUnits(unittest.TestCase): @data({'text': None, 'units': '', 'value': None }, {'text': '', 'units': '', 'value': None }, {'text': 'm', 'units': '', 'value': None }, {'text': 'M', 'units': '', 'value': None }, {'text': '0.', 'units': 'U', 'value': Decimal('0') }, {'text': '1.', 'units': 'U', 'value': Decimal('1') }, {'text': '0', 'units': 'U', 'value': Decimal('0') }, {'text': '1', 'units': 'U', 'value': Decimal('1') },
from qtrf.numeric_suffix import prefix_map # prefixes prefix_map = prefix_map.copy() del (prefix_map['f']) del (prefix_map['p']) del (prefix_map['n']) del (prefix_map['m']) # units units = 'Hz'
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.prefix_keys = prefix_map.copy()