final

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