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"):
...
@@ -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
)
...
...
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