Commit 4a819403 authored by Sergey Bobrov's avatar Sergey Bobrov

The trivial graph parsing test has been debugged

parent 55ad2207
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_):
''' '''
......
...@@ -275,8 +275,8 @@ class Parser(): ...@@ -275,8 +275,8 @@ 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)
comments = [m for m in re.finditer(r'\".*\"', dot)] comments = [m for m in re.finditer(r'\".*\"', dot)]
......
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}
gr.run(data) try:
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):
......
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