27
27
28
28
"""Unit tests for the migrid module pointed to in the filename"""
29
29
30
- import binascii
31
30
from contextlib import contextmanager
32
31
import errno
33
32
import fcntl
34
33
import os
35
34
import sys
36
- import zipfile
37
35
38
- sys .path .append (os .path .realpath (os .path .join (os .path .dirname (__file__ ), "." )))
36
+ sys .path .append (os .path .realpath (
37
+ os .path .join (os .path .dirname (__file__ ), ".." )))
39
38
40
- from support import MigTestCase , fixturepath , temppath , testmain
39
+ from tests . support import MigTestCase , fixturepath , temppath , testmain
41
40
from mig .shared .serverfile import LOCK_EX
42
41
from mig .shared .localfile import LocalFile
43
42
@@ -67,13 +66,12 @@ def assertPathLockedExclusive(self, file_path):
67
66
with open (file_path ) as conflicting_f :
68
67
reraise = None
69
68
try :
70
- fcntl .flock (
71
- conflicting_f , fcntl .LOCK_NB | LOCK_EX )
69
+ fcntl .flock (conflicting_f , fcntl .LOCK_NB | LOCK_EX )
72
70
73
71
# we were errantly able to acquire a lock, mark errored
74
72
reraise = AssertionError ("RERAISE_MUST_UNLOCK" )
75
- except Exception as maybeerr :
76
- if getattr (maybeerr , 'errno' , None ) == errno .EAGAIN :
73
+ except Exception as maybe_err :
74
+ if getattr (maybe_err , 'errno' , None ) == errno .EAGAIN :
77
75
# this is the expected exception - the logic tried to lock
78
76
# a file that was (as we intended) already locked, meaning
79
77
# this assertion has succeeded so we do not need to raise
@@ -87,7 +85,7 @@ def assertPathLockedExclusive(self, file_path):
87
85
if str (reraise ) == 'RERAISE_MUST_UNLOCK' :
88
86
fcntl .flock (conflicting_f , fcntl .LOCK_NB | fcntl .LOCK_UN )
89
87
90
- # raise a user-friendly error to aovid nested raise
88
+ # raise a user-friendly error to avoid nested raise
91
89
raise AssertionError (
92
90
"expected locked file: %s" % self .pretty_display_path (file_path ))
93
91
0 commit comments