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 11
11
from julia import JuliaError
12
12
from julia .core import jl_name , py_name
13
13
14
+ from .utils import retry_failing_if_windows
15
+
14
16
python_version = sys .version_info
15
17
16
18
@@ -155,6 +157,11 @@ def test_module_dir(julia):
155
157
@pytest .mark .pyjulia__using_default_setup
156
158
@pytest .mark .julia
157
159
def test_import_without_setup ():
160
+ check_import_without_setup ()
161
+
162
+
163
+ @retry_failing_if_windows
164
+ def check_import_without_setup ():
158
165
command = [sys .executable , "-c" , "from julia import Base" ]
159
166
print ("Executing:" , * command )
160
167
subprocess .check_call (command )
Original file line number Diff line number Diff line change 1
1
import pytest
2
2
3
3
from julia .core import JuliaInfo
4
+ from julia .tests .utils import retry_failing_if_windows
4
5
5
6
from .test_compatible_exe import runcode
6
7
10
11
@pytest .mark .skipif ("juliainfo.version_info < (0, 7)" )
11
12
@pytest .mark .julia
12
13
def test_compiled_modules_no ():
14
+ check_compiled_modules_no ()
15
+
16
+
17
+ @retry_failing_if_windows
18
+ def check_compiled_modules_no ():
13
19
runcode (
14
20
"""
15
21
from julia.core import Julia
Original file line number Diff line number Diff line change 9
9
from julia .core import UnsupportedPythonError
10
10
11
11
from .test_compatible_exe import runcode
12
+ from .utils import _retry_on_failure , retry_failing_if_windows
12
13
13
14
try :
14
15
from types import SimpleNamespace
@@ -35,9 +36,25 @@ def test_unsupported_python_error_dynamically_linked():
35
36
assert "have to match exactly" in str (err )
36
37
37
38
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
+
38
50
@pytest .mark .pyjulia__using_default_setup
39
51
@pytest .mark .julia
40
52
def test_atexit ():
53
+ check_atexit ()
54
+
55
+
56
+ @retry_failing_if_windows
57
+ def check_atexit ():
41
58
proc = runcode (
42
59
'''
43
60
import os
Original file line number Diff line number Diff line change
1
+ from __future__ import print_function
2
+
1
3
import os
2
4
import sys
5
+ import traceback
6
+ from functools import wraps
3
7
4
8
import pytest
5
9
30
34
"""
31
35
Tests that are known to fail in Windows in GitHub Actions.
32
36
"""
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