File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -459,17 +459,21 @@ def test_trailing_slash(self):
459459 def test_UNC_path (self ):
460460 with open (os .path .join (self .path , 'test_trailing_slash.py' ), 'w' ) as f :
461461 f .write ("testdata = 'test_trailing_slash'" )
462+ importlib .invalidate_caches ()
462463 # Create the UNC path, like \\myhost\c$\foo\bar.
463464 path = os .path .abspath (self .path )
464465 import socket
465466 hn = socket .gethostname ()
466467 drive = path [0 ]
467468 unc = "\\ \\ %s\\ %s$" % (hn , drive )
468469 unc += path [2 :]
469- sys .path .append (path )
470- mod = __import__ ("test_trailing_slash" )
471- self .assertEqual (mod .testdata , 'test_trailing_slash' )
472- unload ("test_trailing_slash" )
470+ sys .path .append (unc )
471+ try :
472+ mod = __import__ ("test_trailing_slash" )
473+ self .assertEqual (mod .testdata , 'test_trailing_slash' )
474+ unload ("test_trailing_slash" )
475+ finally :
476+ sys .path .remove (unc )
473477
474478
475479class RelativeImportTests (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments