Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit 5b76063

Browse files
committed
updated versions
1 parent 189d6b8 commit 5b76063

File tree

5 files changed

+43
-28
lines changed

5 files changed

+43
-28
lines changed

requirements.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
sflkitlib>=0.0.1
22
astor>=0.8.1
3-
numpy==1.25.1
4-
matplotlib==3.7.2
3+
numpy>=1.25.1
4+
matplotlib>=3.7.2
55
sortedcollections>=2.1.0
6-
parameterized>=0.8.1
7-
future>=0.18.3
6+
parameterized>=0.8.1

requirements_test.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
sflkitlib>=0.0.1
22
astor>=0.8.1
3-
numpy==1.25.1
4-
matplotlib==3.7.2
3+
numpy>=1.25.1
4+
matplotlib>=3.7.2
55
sortedcollections>=2.1.0
66
pytest>=7.2.2
77
pytest-cov>=4.1.0
88
pytest-html>=3.2.0
99
pytest-rerunfailures>=11.1.2
10-
parameterized>=0.8.1
11-
future>=0.18.3
10+
parameterized>=0.8.1

setup.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ python_requires = >=3.10
2626
install_requires =
2727
sflkitlib>=0.0.1
2828
astor>=0.8.1
29-
numpy==1.25.1
30-
matplotlib==3.7.2
29+
numpy>=1.25.1
30+
matplotlib>=3.7.2
3131
sortedcollections>=2.1.0
3232
parameterized>=0.8.1
3333

@@ -38,8 +38,8 @@ where = src
3838
test =
3939
sflkitlib>=0.0.1
4040
astor>=0.8.1
41-
numpy==1.25.1
42-
matplotlib==3.7.2
41+
numpy>=1.25.1
42+
matplotlib>=3.7.2
4343
sortedcollections>=2.1.0
4444
pytest>=7.2.2
4545
pytest-cov>=4.1.0

src/sflkit/language/python/visitor.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ def __create_node(self, injection: Injection, node: AST, body=False, doc=None):
7474
)
7575
if injection.error:
7676
error_var = self.meta_visitor.tmp_generator.get_var_name()
77+
raise_stmt = [
78+
Raise(
79+
exc=Name(id=error_var),
80+
cause=None,
81+
)
82+
]
7783
if body:
7884
node.body = (
7985
Try(
@@ -84,7 +90,7 @@ def __create_node(self, injection: Injection, node: AST, body=False, doc=None):
8490
id="BaseException",
8591
),
8692
name=error_var,
87-
body=injection.error,
93+
body=injection.error + raise_stmt,
8894
)
8995
],
9096
orelse=[],
@@ -101,7 +107,7 @@ def __create_node(self, injection: Injection, node: AST, body=False, doc=None):
101107
id="BaseException",
102108
),
103109
name=error_var,
104-
body=injection.error,
110+
body=injection.error + raise_stmt,
105111
)
106112
],
107113
orelse=[],

src/sflkit/runners/run.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
rb"= ((((?P<f>\d+) failed)|((?P<p>\d+) passed)|(\d+ warnings?))(, )?)+ in "
1717
)
1818

19+
DEFAULT_TIMEOUT = 10
20+
1921

2022
class PytestNode(abc.ABC):
2123
def __init__(self, name: str, parent=None):
@@ -141,7 +143,8 @@ def get_dir(self):
141143

142144

143145
class Runner(abc.ABC):
144-
def __init__(self, re_filter: str = r".*"):
146+
def __init__(self, re_filter: str = r".*", timeout=DEFAULT_TIMEOUT):
147+
self.timeout = timeout
145148
self.re_filter = re.compile(re_filter)
146149

147150
def get_tests(self, directory: Path, environ: Environment = None) -> List[str]:
@@ -218,12 +221,16 @@ def __get_pytest_result__(
218221
def run_test(
219222
self, directory: Path, test: str, environ: Environment = None
220223
) -> TestResult:
221-
output = subprocess.run(
222-
["python", "-m", "pytest", test],
223-
stdout=subprocess.PIPE,
224-
env=environ,
225-
cwd=directory,
226-
).stdout
224+
try:
225+
output = subprocess.run(
226+
["python", "-m", "pytest", test],
227+
stdout=subprocess.PIPE,
228+
env=environ,
229+
cwd=directory,
230+
timeout=self.timeout,
231+
).stdout
232+
except subprocess.TimeoutExpired:
233+
return TestResult.UNDEFINED
227234
successful, passing, failing = self.__get_pytest_result__(output)
228235
if successful:
229236
if passing > 0 and failing == 0:
@@ -272,13 +279,17 @@ def run_test(
272279
else:
273280
test = self.failing[test_name]
274281
result = TestResult.FAILING
275-
process = subprocess.run(
276-
["python", self.access] + test,
277-
stdout=subprocess.PIPE,
278-
stderr=subprocess.PIPE,
279-
env=environ,
280-
cwd=directory,
281-
)
282+
try:
283+
process = subprocess.run(
284+
["python", self.access] + test,
285+
stdout=subprocess.PIPE,
286+
stderr=subprocess.PIPE,
287+
env=environ,
288+
cwd=directory,
289+
timeout=self.timeout,
290+
)
291+
except subprocess.TimeoutExpired:
292+
return TestResult.UNDEFINED
282293
self.output[test_name] = (
283294
process.stdout.decode("utf8"),
284295
process.stderr.decode("utf8"),

0 commit comments

Comments
 (0)