1- import  os 
21import  tempfile 
32
3+ from  os  import  path , remove 
4+ 
45from  training  import  dictionary_pickler 
56
6- TEST_DIR  =  os . path .abspath (os . path .dirname (__file__ ))
7+ TEST_DIR  =  path .abspath (path .dirname (__file__ ))
78
89
910def  test_logic () ->  None :
1011    """Test if certain code parts correspond to the intended logic.""" 
1112    # dict generation 
12-     testfile  =  os . path .join (TEST_DIR , "data/zz.txt" )
13+     testfile  =  path .join (TEST_DIR , "data/zz.txt" )
1314    # simple generation, silent mode 
1415    mydict  =  dictionary_pickler ._read_dict (testfile , "zz" , silent = True )
1516    assert  len (mydict ) ==  3 
1617    mydict  =  dictionary_pickler ._load_dict (
17-         "zz" , listpath = os . path .join (TEST_DIR , "data" ), silent = True 
18+         "zz" , listpath = path .join (TEST_DIR , "data" ), silent = True 
1819    )
1920    assert  len (mydict ) ==  3 
2021    # log warning 
@@ -35,11 +36,14 @@ def test_logic() -> None:
3536    assert  dictionary_pickler ._determine_path ("lists" , "de" ).endswith ("de.txt" )
3637
3738    # dict pickling 
38-     listpath  =  os . path .join (TEST_DIR , "data" )
39+     listpath  =  path .join (TEST_DIR , "data" )
3940    os_handle , temp_outputfile  =  tempfile .mkstemp (suffix = ".pkl" , text = True )
4041    dictionary_pickler ._pickle_dict ("zz" , listpath , temp_outputfile )
4142    dictionary_pickler ._pickle_dict ("zz" , listpath , in_place = True )
4243
4344    # remove pickle file 
4445    filepath  =  dictionary_pickler ._determine_pickle_path ("zz" )
45-     os .remove (filepath )
46+     try :
47+         remove (filepath )
48+     except  (AttributeError , FileNotFoundError ):
49+         print ("Pickle file already deleted" )
0 commit comments