1717from aiida .orm .nodes .data .code .installed import InstalledCode
1818
1919
20- def test_constructor_raises (aiida_localhost ):
20+ def test_constructor_raises (aiida_localhost , bash_path ):
2121 """Test the constructor when it is supposed to raise."""
2222 with pytest .raises (TypeError , match = r'missing .* required positional arguments' ):
2323 InstalledCode ()
2424
2525 with pytest .raises (TypeError , match = r'Got object of type .*' ):
26- InstalledCode (computer = aiida_localhost , filepath_executable = pathlib . Path ( '/usr/bin/bash' ) )
26+ InstalledCode (computer = aiida_localhost , filepath_executable = bash_path )
2727
2828 with pytest .raises (TypeError , match = r'Got object of type .*' ):
2929 InstalledCode (computer = 'computer' , filepath_executable = '/usr/bin/bash' )
3030
3131
32- def test_constructor (aiida_localhost ):
32+ def test_constructor (aiida_localhost , bash_path ):
3333 """Test the constructor."""
34- filepath_executable = '/usr/bin/bash'
34+ filepath_executable = str ( bash_path . absolute ())
3535 code = InstalledCode (computer = aiida_localhost , filepath_executable = filepath_executable )
3636 assert code .computer .pk == aiida_localhost .pk
3737 assert code .filepath_executable == pathlib .PurePath (filepath_executable )
3838
3939
40- def test_validate (aiida_localhost ):
40+ def test_validate (aiida_localhost , bash_path ):
4141 """Test the validator is called before storing."""
42- filepath_executable = '/usr/bin/bash'
42+ filepath_executable = str ( bash_path . absolute ())
4343 code = InstalledCode (computer = aiida_localhost , filepath_executable = filepath_executable )
4444
4545 code .computer = aiida_localhost
@@ -53,18 +53,18 @@ def test_validate(aiida_localhost):
5353 assert code .is_stored
5454
5555
56- def test_can_run_on_computer (aiida_localhost ):
56+ def test_can_run_on_computer (aiida_localhost , bash_path ):
5757 """Test the :meth:`aiida.orm.nodes.data.code.installed.InstalledCode.can_run_on_computer` method."""
58- code = InstalledCode (computer = aiida_localhost , filepath_executable = '/usr/bin/bash' )
58+ code = InstalledCode (computer = aiida_localhost , filepath_executable = str ( bash_path . absolute ()) )
5959 computer = Computer ()
6060
6161 assert code .can_run_on_computer (aiida_localhost )
6262 assert not code .can_run_on_computer (computer )
6363
6464
65- def test_filepath_executable (aiida_localhost ):
65+ def test_filepath_executable (aiida_localhost , bash_path , cat_path ):
6666 """Test the :meth:`aiida.orm.nodes.data.code.installed.InstalledCode.filepath_executable` property."""
67- filepath_executable = '/usr/bin/bash'
67+ filepath_executable = str ( bash_path . absolute ())
6868 code = InstalledCode (computer = aiida_localhost , filepath_executable = filepath_executable )
6969 assert code .filepath_executable == pathlib .PurePath (filepath_executable )
7070
@@ -74,7 +74,7 @@ def test_filepath_executable(aiida_localhost):
7474 assert code .filepath_executable == pathlib .PurePath (filepath_executable )
7575
7676 # Change through the property
77- filepath_executable = '/usr/bin/cat'
77+ filepath_executable = str ( cat_path . absolute ())
7878 code .filepath_executable = filepath_executable
7979 assert code .filepath_executable == pathlib .PurePath (filepath_executable )
8080
@@ -101,7 +101,7 @@ def computer(request, aiida_computer_local, aiida_computer_ssh):
101101
102102@pytest .mark .usefixtures ('aiida_profile_clean' )
103103@pytest .mark .parametrize ('computer' , ('core.local' , 'core.ssh' ), indirect = True )
104- def test_validate_filepath_executable (ssh_key , computer ):
104+ def test_validate_filepath_executable (ssh_key , computer , bash_path ):
105105 """Test the :meth:`aiida.orm.nodes.data.code.installed.InstalledCode.validate_filepath_executable` method."""
106106 filepath_executable = '/usr/bin/not-existing'
107107 code = InstalledCode (computer = computer , filepath_executable = filepath_executable )
@@ -117,19 +117,19 @@ def test_validate_filepath_executable(ssh_key, computer):
117117 with pytest .raises (ValidationError , match = r'The provided remote absolute path .* does not exist on the computer\.' ):
118118 code .validate_filepath_executable ()
119119
120- code .filepath_executable = '/usr/bin/bash'
120+ code .filepath_executable = str ( bash_path . absolute ())
121121 code .validate_filepath_executable ()
122122
123123
124- def test_full_label (aiida_localhost ):
124+ def test_full_label (aiida_localhost , bash_path ):
125125 """Test the :meth:`aiida.orm.nodes.data.code.installed.InstalledCode.full_label` property."""
126126 label = 'some-label'
127- code = InstalledCode (label = label , computer = aiida_localhost , filepath_executable = '/usr/bin/bash' )
127+ code = InstalledCode (label = label , computer = aiida_localhost , filepath_executable = str ( bash_path . absolute ()) )
128128 assert code .full_label == f'{ label } @{ aiida_localhost .label } '
129129
130130
131- def test_get_execname (aiida_localhost ):
131+ def test_get_execname (aiida_localhost , bash_path ):
132132 """Test the deprecated :meth:`aiida.orm.nodes.data.code.installed.InstalledCode.get_execname` method."""
133- code = InstalledCode (label = 'some-label' , computer = aiida_localhost , filepath_executable = '/usr/bin/bash' )
133+ code = InstalledCode (label = 'some-label' , computer = aiida_localhost , filepath_executable = str ( bash_path . absolute ()) )
134134 with pytest .warns (AiidaDeprecationWarning ):
135- assert code .get_execname () == '/usr/bin/bash'
135+ assert code .get_execname () == str ( bash_path . absolute ())
0 commit comments