File tree Expand file tree Collapse file tree 4 files changed +64
-0
lines changed Expand file tree Collapse file tree 4 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 1111from julia import JuliaError
1212from julia .core import jl_name , py_name
1313
14+ from .utils import retry_failing_if_windows
15+
1416python_version = sys .version_info
1517
1618
@@ -155,6 +157,11 @@ def test_module_dir(julia):
155157@pytest .mark .pyjulia__using_default_setup
156158@pytest .mark .julia
157159def test_import_without_setup ():
160+ check_import_without_setup ()
161+
162+
163+ @retry_failing_if_windows
164+ def check_import_without_setup ():
158165 command = [sys .executable , "-c" , "from julia import Base" ]
159166 print ("Executing:" , * command )
160167 subprocess .check_call (command )
Original file line number Diff line number Diff line change 11import pytest
22
33from julia .core import JuliaInfo
4+ from julia .tests .utils import retry_failing_if_windows
45
56from .test_compatible_exe import runcode
67
1011@pytest .mark .skipif ("juliainfo.version_info < (0, 7)" )
1112@pytest .mark .julia
1213def test_compiled_modules_no ():
14+ check_compiled_modules_no ()
15+
16+
17+ @retry_failing_if_windows
18+ def check_compiled_modules_no ():
1319 runcode (
1420 """
1521 from julia.core import Julia
Original file line number Diff line number Diff line change 99from julia .core import UnsupportedPythonError
1010
1111from .test_compatible_exe import runcode
12+ from .utils import _retry_on_failure , retry_failing_if_windows
1213
1314try :
1415 from types import SimpleNamespace
@@ -35,9 +36,25 @@ def test_unsupported_python_error_dynamically_linked():
3536 assert "have to match exactly" in str (err )
3637
3738
39+ def test_retry_on_failure ():
40+ c = [0 ]
41+
42+ def f ():
43+ c [0 ] += 1
44+ assert c [0 ] >= 2
45+
46+ _retry_on_failure (f )
47+ assert c [0 ] == 2
48+
49+
3850@pytest .mark .pyjulia__using_default_setup
3951@pytest .mark .julia
4052def test_atexit ():
53+ check_atexit ()
54+
55+
56+ @retry_failing_if_windows
57+ def check_atexit ():
4158 proc = runcode (
4259 '''
4360 import os
Original file line number Diff line number Diff line change 1+ from __future__ import print_function
2+
13import os
24import sys
5+ import traceback
6+ from functools import wraps
37
48import pytest
59
3034"""
3135Tests that are known to fail in Windows in GitHub Actions.
3236"""
37+
38+
39+ def _retry_on_failure (* fargs , ** kwargs ):
40+ f = fargs [0 ]
41+ args = fargs [1 :]
42+ for i in range (10 ):
43+ try :
44+ return f (* args , ** kwargs )
45+ except Exception :
46+ print ()
47+ print ("{}-th try of {} failed" .format (i , f ))
48+ traceback .print_exc ()
49+ return f (* args , ** kwargs )
50+
51+
52+ def retry_failing_if_windows (test ):
53+ """
54+ Retry upon test failure if in Windows.
55+
56+ This is an ugly workaround for occasional STATUS_ACCESS_VIOLATION failures
57+ in Windows: https://github.com/JuliaPy/pyjulia/issues/462
58+ """
59+ if not is_windows :
60+ return test
61+
62+ @wraps (test )
63+ def repeater (* args , ** kwargs ):
64+ _retry_on_failure (test , * args , ** kwargs )
65+
66+ return repeater
You can’t perform that action at this time.
0 commit comments