Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pycomsdk
Project
Project
Details
Activity
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
com
pycomsdk
Commits
4a819403
Commit
4a819403
authored
Mar 28, 2025
by
Sergey Bobrov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The trivial graph parsing test has been debugged
parent
55ad2207
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
3 deletions
+10
-3
misc.py
comsdk/misc.py
+2
-1
parser.py
comsdk/parser.py
+1
-1
test_parser.py
tests/test_parser.py
+7
-1
No files found.
comsdk/misc.py
View file @
4a819403
import
shutil
from
functools
import
reduce
,
partial
from
functools
import
reduce
,
partial
import
os
import
os
import
re
import
re
...
@@ -163,7 +164,7 @@ def is_sequence(obj):
...
@@ -163,7 +164,7 @@ def is_sequence(obj):
'''
'''
Checks whether obj is a sequence (string does not count as a sequence)
Checks whether obj is a sequence (string does not count as a sequence)
'''
'''
return
isinstance
(
obj
,
collections
.
Sequence
)
and
(
not
hasattr
(
obj
,
'strip'
))
return
isinstance
(
obj
,
collections
.
abc
.
Sequence
)
and
(
not
hasattr
(
obj
,
'strip'
))
def
cp
(
from_
,
to_
):
def
cp
(
from_
,
to_
):
'''
'''
...
...
comsdk/parser.py
View file @
4a819403
...
@@ -275,7 +275,7 @@ class Parser():
...
@@ -275,7 +275,7 @@ class Parser():
def
parse_file
(
self
,
filename
):
def
parse_file
(
self
,
filename
):
# @todo В случае, если на вход будет подан файл в отличной от UTF-8 кодировке программа работать не будет
# @todo В случае, если на вход будет подан файл в отличной от UTF-8 кодировке программа работать не будет
file
=
open
(
filename
,
encoding
=
'utf-8'
)
# "r")
with
open
(
filename
,
"r"
,
encoding
=
"utf-8"
)
as
file
:
dot
=
file
.
read
()
dot
=
file
.
read
()
self
.
_check_brackets
(
dot
)
self
.
_check_brackets
(
dot
)
...
...
tests/test_parser.py
View file @
4a819403
import
gc
import
unittest
import
unittest
import
subprocess
import
subprocess
...
@@ -9,11 +10,16 @@ path_to_pycomsdk = "/home/lbstr/bmstu/pycomsdk"
...
@@ -9,11 +10,16 @@ path_to_pycomsdk = "/home/lbstr/bmstu/pycomsdk"
class
ParserGoodCheck
(
unittest
.
TestCase
):
class
ParserGoodCheck
(
unittest
.
TestCase
):
def
test_trivial_graph
(
self
):
def
test_trivial_graph
(
self
):
parsr
=
Parser
()
parsr
=
Parser
()
gr
=
parsr
.
parse_file
(
"./
tests/
adot/trivial.adot"
)
gr
=
parsr
.
parse_file
(
"./adot/trivial.adot"
)
data
=
{
"a"
:
1
}
data
=
{
"a"
:
1
}
try
:
gr
.
run
(
data
)
gr
.
run
(
data
)
finally
:
# Явный вызов сборщика мусора для очистки ресурсов
gc
.
collect
()
self
.
assertEqual
(
data
[
"a"
],
4
)
self
.
assertEqual
(
data
[
"a"
],
4
)
def
test_branching_graph
(
self
):
def
test_branching_graph
(
self
):
...
...
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