Skip to content

Commit

Permalink
test_all_plugins conflict when run in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Nov 21, 2024
1 parent 3bf2c72 commit e740a0e
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions tests/transports/test_all_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@


@pytest.fixture(scope='function', params=entry_point.get_entry_point_names('aiida.transports'))
def custom_transport(request, tmp_path, monkeypatch) -> Transport:
def custom_transport(request, tmp_path_factory, monkeypatch) -> Transport:
"""Fixture that parametrizes over all the registered implementations of the ``CommonRelaxWorkChain``."""
plugin = TransportFactory(request.param)

if request.param == 'core.ssh':
kwargs = {'machine': 'localhost', 'timeout': 30, 'load_system_host_keys': True, 'key_policy': 'AutoAddPolicy'}
elif request.param == 'core.ssh_auto':
kwargs = {'machine': 'localhost'}
filepath_config = tmp_path / 'config'
filepath_config = tmp_path_factory.mktemp("transport") / 'config'
monkeypatch.setattr(plugin, 'FILEPATH_CONFIG', filepath_config)
if not filepath_config.exists():
filepath_config.write_text('Host localhost')
Expand All @@ -61,27 +61,24 @@ def test_is_open(custom_transport):

assert not custom_transport.is_open


def test_makedirs(custom_transport):
"""Verify the functioning of makedirs command"""
def test_deprecated_chdir_getcwd(custom_transport):
"""Test to be deprecated ``chdir``/``getcwd`` methods still work."""
with custom_transport as transport:
location = transport.normalize(os.path.join('/', 'tmp'))
directory = 'temp_dir_test'
transport.chdir(location)

assert location == transport.getcwd()
while transport.isdir(directory):
# I append a random letter/number until it is unique
directory += random.choice(string.ascii_uppercase + string.digits)
transport.mkdir(directory)
transport.chdir(directory)

def test_makedirs(custom_transport, tmp_path):
"""Verify the functioning of makedirs command"""
with custom_transport as transport:
# define folder structure
dir_tree = os.path.join('1', '2')
dir_tree = str(tmp_path / '1' / '2')
# I create the tree
transport.makedirs(dir_tree)
# verify the existence
assert transport.isdir('1')
assert transport.isdir(str(tmp_path / '1'))
assert dir_tree

# try to recreate the same folder
Expand All @@ -92,11 +89,7 @@ def test_makedirs(custom_transport):
transport.makedirs(dir_tree, True)

transport.rmdir(dir_tree)
transport.rmdir('1')

transport.chdir('..')
transport.rmdir(directory)

transport.rmdir(str(tmp_path / '1'))

def test_rmtree(custom_transport):
"""Verify the functioning of rmtree command"""
Expand Down

0 comments on commit e740a0e

Please sign in to comment.