final

parent 08eae066
...@@ -11,15 +11,20 @@ def load_params(file="params.ini"): ...@@ -11,15 +11,20 @@ def load_params(file="params.ini"):
которым по умолчанию является params.ini ''' которым по умолчанию является params.ini '''
global PARAMS global PARAMS
with open(file, 'r', errors='ignore') as f: try:
lines = f.readlines() open(file, 'r', errors='ignore')
for l in lines: except FileNotFoundError:
param = l.split('=') print("Такого файла с параметрами не существует")
param[1] = param[1].strip('\n') else:
with open(file, 'r', errors='ignore') as f:
lines = f.readlines()
for l in lines:
param = l.split('=')
param[1] = param[1].strip('\n')
if param[0] != 'dest': if param[0] != 'dest':
param[1] = eval(param[1]) param[1] = eval(param[1])
PARAMS[param[0]] = param[1] PARAMS[param[0]] = param[1]
def convert_precision(prec): def convert_precision(prec):
'''' ''''
...@@ -132,7 +137,8 @@ class TestCalculator(unittest.TestCase): ...@@ -132,7 +137,8 @@ class TestCalculator(unittest.TestCase):
def test_precision(self): def test_precision(self):
self.assertEqual(convert_precision(0.0000001), 7) self.assertEqual(convert_precision(0.0000001), 7)
self.assertEqual(convert_precision(0.001), 3)
def test_error(self): def test_error(self):
with self.assertRaises(Exception): with self.assertRaises(Exception):
calculate(*(5,0), action="/", **PARAMS) calculate(*(5,0), action="/", **PARAMS)
......
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