2020# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121# SOFTWARE.
2222
23- import os
23+ from pathlib import Path
2424import conftest
2525import tempfile
2626from ansys .dpf import core
@@ -31,10 +31,10 @@ def get_log_file(log_path, server):
3131 if not isinstance (server , core .server_types .InProcessServer ):
3232 core .core .download_file (
3333 log_path ,
34- os . path . join ( tempfile .gettempdir (), "log2.txt" ),
34+ str ( Path ( tempfile .gettempdir ()) / "log2.txt" ),
3535 server = server ,
3636 )
37- return os . path . join ( tempfile .gettempdir (), "log2.txt" )
37+ return str ( Path ( tempfile .gettempdir ()) / "log2.txt" )
3838 else :
3939 return log_path
4040
@@ -47,14 +47,14 @@ def test_logging(tmpdir, server_type):
4747 examples .find_static_rst (return_local_path = True , server = server_type ),
4848 server = server_type ,
4949 )
50- log_path = os . path . join (server_tmp , "log.txt" )
50+ log_path = Path (server_tmp ) / "log.txt"
5151 else :
52- log_path = os . path . join (tmpdir , "log.txt" )
52+ log_path = Path (tmpdir ) / "log.txt"
5353 result_file = examples .find_static_rst (server = server_type )
5454
5555 # 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 )
5858
5959 wf = core .Workflow (server = server_type )
6060 wf .progress_bar = False
@@ -65,13 +65,13 @@ def test_logging(tmpdir, server_type):
6565 wf .set_output_name ("out" , to_nodal .outputs .fields_container )
6666
6767 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
7171 assert file_size > 20
7272 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
7575
7676 wf = core .Workflow (server = server_type )
7777 wf .progress_bar = False
@@ -82,8 +82,8 @@ def test_logging(tmpdir, server_type):
8282 wf .set_output_name ("out" , to_nodal .outputs .fields_container )
8383
8484 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
8787
8888
8989@conftest .raises_for_servers_version_under ("6.1" )
@@ -93,8 +93,8 @@ def test_logging_remote(tmpdir, server_type_remote_process):
9393 examples .find_multishells_rst (return_local_path = True ),
9494 server = server_type_remote_process ,
9595 )
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 )
9898 server_type_remote_process .session .start_emitting_rpc_log ()
9999
100100 wf = core .Workflow (server = server_type_remote_process )
@@ -107,13 +107,13 @@ def test_logging_remote(tmpdir, server_type_remote_process):
107107 wf .set_output_name ("out" , to_nodal .outputs .fields_container )
108108
109109 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
113113 assert file_size > 3000
114114 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
117117
118118 wf = core .Workflow (server = server_type_remote_process )
119119 wf .progress_bar = False
@@ -125,5 +125,5 @@ def test_logging_remote(tmpdir, server_type_remote_process):
125125 wf .set_output_name ("out" , to_nodal .outputs .fields_container )
126126
127127 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