<s> import os . path <EOL> import pytest <EOL> from conda . lock import Locked , LockError <EOL> def test_lock_passes ( tmpdir ) : <EOL> with Locked ( tmpdir . strpath ) as lock : <EOL> path = os . path . basename ( lock . lock_path ) <EOL> assert tmpdir . join ( path ) . exists ( ) and tmpdir . join ( path ) . isdir ( ) <EOL> assert not tmpdir . join ( path ) . exists ( ) <EOL> assert not tmpdir . exists ( ) <EOL> def test_lock_locks ( tmpdir ) : <EOL> with Locked ( tmpdir . strpath ) as lock1 : <EOL> path = os . path . basename ( lock1 . lock_path ) <EOL> assert tmpdir . join ( path ) . exists ( ) and tmpdir . join ( path ) . isdir ( ) <EOL> with pytest . raises ( LockError ) as execinfo : <EOL> with Locked ( tmpdir . strpath , retries = <NUM_LIT:1> ) as lock2 : <EOL> assert False <EOL> assert lock2 . lock_path == lock1 . lock_path <EOL> assert "<STR_LIT>" in str ( execinfo ) <EOL> assert "<STR_LIT>" in str ( execinfo ) <EOL> assert tmpdir . join ( path ) . exists ( ) and tmpdir . join ( path ) . isdir ( ) <EOL> assert not tmpdir . join ( path ) . exists ( ) <EOL> assert not tmpdir . exists ( ) </s>
