diff --git a/test/mute-stdio/Makefile b/test/cast/Makefile similarity index 100% rename from test/mute-stdio/Makefile rename to test/cast/Makefile diff --git a/test/cast/main.py b/test/cast/main.py index cdb1115..f947684 100644 --- a/test/cast/main.py +++ b/test/cast/main.py @@ -1,9 +1,11 @@ -from jwutils.cast import * -from jwutils.log import * +from jw.util.cast import cast_str, guess_type +from jw.util.log import ERR, INFO, set_flags, set_level, slog -set_level(DEBUG) +set_level('debug') set_flags('console,color,position,prio') +# fmt: disable # don't conflate +# yapf: disable # don't conflate test_data = [ (bool, 'true', True, True), (bool, 'False', True, False), @@ -27,13 +29,15 @@ test_data = [ (str, None, Exception(), Exception()), (str, 'This is a string', 'This is a string', 'This is a string') ] +# fmt: ensable # don't conflate +# yapf: ensable # don't conflate status = 0 for tp, s, guessed_val, cast_val in test_data: try: - slog(INFO, f'guessed type of "{s}" = "{guess_type(s)}", should be "{tp}"') - slog(INFO, f'cast_str("{s}") = "{cast_str(s)}"') - slog(INFO, f'cast_str("{s}, {tp}") = "{cast_str(s, target_type=tp)}"') + slog(INFO, f'guessed type of "{s}" = "{guess_type(s)}", should be "{tp}"') # type: ignore + slog(INFO, f'cast_str("{s}") = "{cast_str(s)}"') # type: ignore + slog(INFO, f'cast_str("{s}, {tp}") = "{cast_str(s, target_type=tp)}"') # type: ignore except Exception as e: if s is None: slog(INFO, f'guessed type of "{s}" = Exception, should be "Exception"') diff --git a/test/mute-stdio/main.py b/test/mute-stdio/main.py deleted file mode 100644 index 84b7918..0000000 --- a/test/mute-stdio/main.py +++ /dev/null @@ -1,14 +0,0 @@ -import jwutils - -print "This is without muted output" - -with jwutils.MuteStdIO(): - print "This is with muted output" - -with jwutils.MuteStdIO(): - print "This will have an error" - print "Second suppressed line of output" - print "Third suppressed line of output" - raise Exception("Something went wrong") - -print "Output is unmuted again" diff --git a/test/parse-opts/Makefile b/test/parse_opts/Makefile similarity index 100% rename from test/parse-opts/Makefile rename to test/parse_opts/Makefile diff --git a/test/parse-opts/test.py b/test/parse_opts/test.py similarity index 63% rename from test/parse-opts/test.py rename to test/parse_opts/test.py index f974c89..6478131 100644 --- a/test/parse-opts/test.py +++ b/test/parse_opts/test.py @@ -1,8 +1,10 @@ -from jwutils.log import * -from jwutils.Options import * +from jw.util.log import NOTICE, slog +from jw.util.Options import Options + +i: str | int delim = "======================= " -d = "----------------------- " +d = "----------------------- " s = "this=that a=b doit" slog(NOTICE, d + s) @@ -11,9 +13,9 @@ slog(NOTICE, d + "dump()") a.dump(NOTICE) slog(NOTICE, d + "by index") for i in range(0, 4): - slog(NOTICE, "attr({}) = {}".format(i, a.get(i, by_index=True, default=False))) + slog(NOTICE, "attr({}) = {}".format(i, a.get(i, by_index = True, default = False))) slog(NOTICE, d + "by key") -for i in [ "this", "that", "b", "a", "doit"]: +for i in ["this", "that", "b", "a", "doit"]: slog(NOTICE, "attr({}) = {}".format(i, a[i])) s = '"me": "too", "Pfalse": true, "myarr": ["a", "b", "c"], "me": "not"' @@ -23,10 +25,10 @@ slog(NOTICE, d + "dump()") a.dump(NOTICE) slog(NOTICE, d + "by index") for i in range(0, 5): - slog(NOTICE, "attr({}) = {}".format(i, a.get(i, by_index=True, default=False))) + slog(NOTICE, "attr({}) = {}".format(i, a.get(i, by_index = True, default = False))) slog(NOTICE, d + "by key in keys()") for i in a.keys(): slog(NOTICE, "attr({}) = {}".format(i, a[i])) slog(NOTICE, d + "by key") -for i in [ "me", "Pfalse", "myarr" ]: +for i in ["me", "Pfalse", "myarr"]: slog(NOTICE, "attr({}) = {}".format(i, a[i])) diff --git a/test/trim-src/Makefile b/test/trim_src/Makefile similarity index 100% rename from test/trim-src/Makefile rename to test/trim_src/Makefile