• Éric Araujo's avatar
    Clean up test_shutil, to facilitate upcoming improvements (#12721). · a7e33a10
    Éric Araujo authored
    The tests now have two convenience functions to wrap os.path.join, open
    and read or write instead of four or six slightly different functions.
    The new functions accept a tuple of path segments but not a list
    anymore, as it makes no sense to use a list here; I have also removed
    the default value for the contents in write_file, as I find it better to
    have the contents at the call site.
    
    For simple open then read/write calls, I have left the usual idiom (with
    open + read/write), as it is short and readable enough.
    
    I’ve also changed some convoluted cleanup code to just use rmtree, and
    removed dubious LBYL os.path.exists checks.  The tests still pass on my
    machine, and leave no file in $TMP.  test_shutil is not as clean as it
    could be, but I’ll stop here.
    
    Initial patch provided by Hynek Schlawack, in preparation for a new
    feature with new tests in #12715.
    a7e33a10
test_shutil.py 33.8 KB