def test_save_shoe(self): '''! test method save_shoe() ''' shoe = Shoe() #default single deck #no shuffle so we can test a simple single deck in order temp_file = os.sep + 'tmp' + os.sep + 'ut1.shoe' delete_file(temp_file) shoe.save_shoe(temp_file) expect = "Ac 2c 3c 4c 5c 6c 7c \n"+\ "8c 9c Tc Jc Qc \n"+\ "Kc Ad 2d 3d 4d \n"+\ "5d 6d 7d 8d 9d \n"+\ "Td Jd Qd Kd Ah \n"+\ "2h 3h 4h 5h 6h \n"+\ "7h 8h 9h Th Jh \n"+\ "Qh Kh As 2s 3s \n"+\ "4s 5s 6s 7s 8s 9s Ts Js Qs Ks \n" with open(temp_file, 'r') as f: actual = f.read() self.assertEqual(expect, actual, "saved single unshuffled deck")
help="instead of playing just create and save a random shoe") parser.add_argument("--use", dest="use_filespec", help="use a saved shoe instead of random generation") parser.add_argument("--just_boards", type=str2bool, nargs='?', const=True, default=False, help="Just use the program to display board results") args = parser.parse_args() if args.use_filespec is not None: if args.create_filespec is not None: raise ValueError("can not use both --create and --use at same time") # --use creates an empty shoe, then fill from a saved file shoe = Shoe(0) shoe.load_shoe(args.use_filespec) play(shoe) else: # generate a new random shoe if args.create_filespec is not None: shoe = Shoe(8) shoe.shuffle() # --create saves the new shoe and exists shoe.save_shoe(args.create_filespec) shoe = None else: if args.just_boards: just_boards() else: play() # END #