Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sem3-ivt19-task1-1-mozgovoy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Мозговой Никита Александрович
sem3-ivt19-task1-1-mozgovoy
Commits
7d3efded
Commit
7d3efded
authored
Dec 10, 2020
by
Мозговой Никита Александрович
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
final
parent
08eae066
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
calculate.py
calculate.py
+15
-9
No files found.
calculate.py
View file @
7d3efded
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment