20
20
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
# SOFTWARE.
22
22
23
- import os
23
+ from pathlib import Path
24
24
import conftest
25
25
import tempfile
26
26
from ansys .dpf import core
@@ -31,10 +31,10 @@ def get_log_file(log_path, server):
31
31
if not isinstance (server , core .server_types .InProcessServer ):
32
32
core .core .download_file (
33
33
log_path ,
34
- os . path . join ( tempfile .gettempdir (), "log2.txt" ),
34
+ str ( Path ( tempfile .gettempdir ()) / "log2.txt" ),
35
35
server = server ,
36
36
)
37
- return os . path . join ( tempfile .gettempdir (), "log2.txt" )
37
+ return str ( Path ( tempfile .gettempdir ()) / "log2.txt" )
38
38
else :
39
39
return log_path
40
40
@@ -47,14 +47,14 @@ def test_logging(tmpdir, server_type):
47
47
examples .find_static_rst (return_local_path = True , server = server_type ),
48
48
server = server_type ,
49
49
)
50
- log_path = os . path . join (server_tmp , "log.txt" )
50
+ log_path = Path (server_tmp ) / "log.txt"
51
51
else :
52
- log_path = os . path . join (tmpdir , "log.txt" )
52
+ log_path = Path (tmpdir ) / "log.txt"
53
53
result_file = examples .find_static_rst (server = server_type )
54
54
55
55
# download it
56
- new_tmpdir = os . path . join (tmpdir , "my_tmp_dir" )
57
- server_type .session .handle_events_with_file_logger (log_path , 2 )
56
+ _ = Path (tmpdir ) / "my_tmp_dir"
57
+ server_type .session .handle_events_with_file_logger (str ( log_path ) , 2 )
58
58
59
59
wf = core .Workflow (server = server_type )
60
60
wf .progress_bar = False
@@ -65,13 +65,13 @@ def test_logging(tmpdir, server_type):
65
65
wf .set_output_name ("out" , to_nodal .outputs .fields_container )
66
66
67
67
wf .get_output ("out" , core .types .fields_container )
68
- download_log_path = get_log_file (log_path , server_type )
69
- assert os . path . exists (download_log_path )
70
- file_size = os . path . getsize ( download_log_path )
68
+ download_log_path = Path ( get_log_file (str ( log_path ) , server_type ) )
69
+ assert download_log_path . exists ()
70
+ file_size = download_log_path . stat (). st_size
71
71
assert file_size > 20
72
72
server_type ._del_session ()
73
- download_log_path = get_log_file (log_path , server_type )
74
- file_size = os . path . getsize ( download_log_path )
73
+ download_log_path = Path ( get_log_file (str ( log_path ) , server_type ) )
74
+ file_size = download_log_path . stat (). st_size
75
75
76
76
wf = core .Workflow (server = server_type )
77
77
wf .progress_bar = False
@@ -82,8 +82,8 @@ def test_logging(tmpdir, server_type):
82
82
wf .set_output_name ("out" , to_nodal .outputs .fields_container )
83
83
84
84
wf .get_output ("out" , core .types .fields_container )
85
- download_log_path = get_log_file (log_path , server_type )
86
- assert file_size == os . path . getsize ( download_log_path )
85
+ download_log_path = Path ( get_log_file (str ( log_path ) , server_type ) )
86
+ assert file_size == download_log_path . stat (). st_size
87
87
88
88
89
89
@conftest .raises_for_servers_version_under ("6.1" )
@@ -93,8 +93,8 @@ def test_logging_remote(tmpdir, server_type_remote_process):
93
93
examples .find_multishells_rst (return_local_path = True ),
94
94
server = server_type_remote_process ,
95
95
)
96
- log_path = os . path . join (server_tmp , "log.txt" )
97
- server_type_remote_process .session .handle_events_with_file_logger (log_path , 2 )
96
+ log_path = Path (server_tmp ) / "log.txt"
97
+ server_type_remote_process .session .handle_events_with_file_logger (str ( log_path ) , 2 )
98
98
server_type_remote_process .session .start_emitting_rpc_log ()
99
99
100
100
wf = core .Workflow (server = server_type_remote_process )
@@ -107,13 +107,13 @@ def test_logging_remote(tmpdir, server_type_remote_process):
107
107
wf .set_output_name ("out" , to_nodal .outputs .fields_container )
108
108
109
109
wf .get_output ("out" , core .types .fields_container )
110
- download_log_path = get_log_file (log_path , server_type_remote_process )
111
- assert os . path . exists (download_log_path )
112
- file_size = os . path . getsize ( download_log_path )
110
+ download_log_path = Path ( get_log_file (str ( log_path ) , server_type_remote_process ) )
111
+ assert download_log_path . exists ()
112
+ file_size = download_log_path . stat (). st_size
113
113
assert file_size > 3000
114
114
server_type_remote_process ._del_session ()
115
- download_log_path = get_log_file (log_path , server_type_remote_process )
116
- file_size = os . path . getsize ( download_log_path )
115
+ download_log_path = Path ( get_log_file (str ( log_path ) , server_type_remote_process ) )
116
+ file_size = download_log_path . stat (). st_size
117
117
118
118
wf = core .Workflow (server = server_type_remote_process )
119
119
wf .progress_bar = False
@@ -125,5 +125,5 @@ def test_logging_remote(tmpdir, server_type_remote_process):
125
125
wf .set_output_name ("out" , to_nodal .outputs .fields_container )
126
126
127
127
wf .get_output ("out" , core .types .fields_container )
128
- download_log_path = get_log_file (log_path , server_type_remote_process )
129
- assert file_size == os . path . getsize ( download_log_path )
128
+ download_log_path = Path ( get_log_file (str ( log_path ) , server_type_remote_process ) )
129
+ assert file_size == download_log_path . stat (). st_size
0 commit comments