~thestr4ng3r/mymcplus

fd0fe62d865be403853b8239f1babe90b59b6cdf — Florian Märkl 3 years ago 174f858
Add ASCII option to dir, Add Test for dir
2 files changed, 24 insertions(+), 2 deletions(-)

M mymc/mymc.py
M test/memorycard.py
M mymc/mymc.py => mymc/mymc.py +6 -2
@@ 361,7 361,10 @@ def do_dir(cmd, mc, opts, args, opterr):
			dirname = "/" + ent[8]
			mc.chdir(dirname)
			length = mc.dir_size(".");
			enc = getattr(sys.stdout, "encoding", None)
			if opts.ascii:
				enc = "ascii"
			else:
				enc = getattr(sys.stdout, "encoding", None)
			if dirmode & DF_PSX:
				title = _get_psx_title(mc, ent[8], enc)
			else:


@@ 617,7 620,8 @@ cmd_table = {
	"dir": (do_dir, "rb",
		None,
		"Display save file information.",
		[]),
		[opt("-a", "--ascii", action="store_true",
			 help = "Output names in ASCII")]),
	"df": (do_df, "rb",
	       None,
	       "Display the amount free space.",

M test/memorycard.py => test/memorycard.py +18 -0
@@ 163,3 163,21 @@ def test_df(capsys, data):
    output = capsys.readouterr()
    assert output.out == mc_file + ": 8268800 bytes free.\n"
    assert output.err == ""


def test_dir(monkeypatch, capsys, data):
    mc_file = data.join("mc01.ps2").strpath

    mymc.main(["mymc",
               "-i", mc_file,
               "dir", "-a"])

    output = capsys.readouterr()
    assert output.out == ("BEDATA-SYSTEM                    Your System\n"
                          "   5KB Not Protected             Configuration\n"
                          "\n"
                          "BESCES-50501REZ                  Rez\n"
                          "  53KB Not Protected             \n"
                          "\n"
                          "8,075 KB Free\n")
    assert output.err == ""
\ No newline at end of file