File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import sys
1010from collections import OrderedDict
1111from concurrent .futures import ThreadPoolExecutor
12+ from datetime import datetime
1213from io import StringIO
1314from multiprocessing import cpu_count
1415from pathlib import Path
@@ -376,7 +377,12 @@ def format(
376377 if overwrite_file :
377378 if result :
378379 if backup :
379- shutil .copyfile (self .stan_file , self .stan_file + '.bak' )
380+ shutil .copyfile (
381+ self .stan_file ,
382+ self .stan_file
383+ + '.bak-'
384+ + datetime .now ().strftime ("%Y%m%d%H%M%S" ),
385+ )
380386 with (open (self .stan_file , 'w' )) as file_handle :
381387 file_handle .write (result )
382388 else :
Original file line number Diff line number Diff line change 66# and we re-ignore hpp and exe files
77* .hpp
88* .exe
9- * . * bak
9+ * .testbak
10+ * .bak- *
1011! return_one.hpp
Original file line number Diff line number Diff line change 77import shutil
88import tempfile
99import unittest
10+ from glob import glob
1011from test import CustomTestCase
1112from unittest .mock import MagicMock , patch
1213
@@ -409,7 +410,7 @@ def test_model_format_deprecations(self):
409410 shutil .copy (stan , stan + '.testbak' )
410411 try :
411412 model .format (overwrite_file = True , canonicalize = True )
412- self .assertTrue ( os . path . exists ( stan + '.bak' ) )
413+ self .assertEqual ( len ( glob ( stan + '.bak-*' )), 1 )
413414 finally :
414415 shutil .copy (stan + '.testbak' , stan )
415416
You can’t perform that action at this time.
0 commit comments