From 37b69fd1580d87be4322811e9fb9cd39dd6d4e0f Mon Sep 17 00:00:00 2001 From: enkore Date: Fri, 8 Mar 2013 16:00:42 +0100 Subject: [PATCH] Hey, how about some determenistic tests? Wouldn't that be real great? --- tests/test_battery.py | 4 ---- tests/test_core_util.py | 43 ++++++++++++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/tests/test_battery.py b/tests/test_battery.py index 4019ad1..11485c2 100755 --- a/tests/test_battery.py +++ b/tests/test_battery.py @@ -27,7 +27,3 @@ def basic_test_generator(): yield factory(path, "{status}", status) yield factory(path, "{consumption:.3f}", consumption) yield factory(path, "{remaining_hm}", remaining) - - -#suite = unittest.TestLoader().loadTestsFromName(__name__) -#unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/tests/test_core_util.py b/tests/test_core_util.py index 11bf3f7..f35c700 100644 --- a/tests/test_core_util.py +++ b/tests/test_core_util.py @@ -21,17 +21,45 @@ def lchop_factory(prefix, string): return test def lchop_test_generator(): - nmin = 5 - nmax = 20 - for n in range(nmin, nmax): - prefix = get_random_string(n) - string = get_random_string(2*nmax-n) + cases = [ + ('\x0b,S0I', "=t5Bk+\x0b'_;duq=9"), + ('H1@\x0b_\t', '<&9<;Q(0L";^$7'), + ('NWV#B0u', '~Q_wx5"$W\x0b[(T'), + ('by=uHfZ>', 'AdytjC5-OUR\\'), + ('/FD|^6=m3', 'l0:%ibW7*}S'), + ('!.LsV90/$\x0b', 'nD}L&4]MGC'), + ('S0zOIvbm:~L', 'jJ\\UGOMY<'), + ("'aZ@,AA\x0b;Dmm", 'ZD +9}f;'), + ('Ae;=SoHD(1VPJ', 'x\r)du,+'), + ('ANDT \t>tZ1Iy9}', 'wpz%F`'), + ('|w?>bv,t# BkGeE', '07mZR'), + ('1MSN\x0c\r}Tu8r3uCe)', '\\I6-'), + ('0;-!MVW4+\rz]J3@SQ', 'lvG'), + ('Zi\x0b^5E?}a\\KJ(,O4n(', '8:'), + ('I-X[~2sQigGLA_~ZD%G', '#'), + (':xio!', 'v=ApOu\t_,}'), + ('%bM%W\n', '7$wZ]gaL!U/%'), + ('~\x0bILq>+', '[4}LhQ1zz1m?D&'), + ('+"a)\x0c:4Q', '\niNQ+GY8+)UtQ\r#M'), + ('R3PHi/[S*', 'J7fV19X(c^^J(9BAY+'), + ('%Z?=m|3Wtr', 'O7K%GpQRJR%y}wIDq~H\\'), + ('wyR0V*y^+D)', '>tsX)@%=u[83/hf0j?+xXV'), + ('4}joZKr?j$u)', '\r\x0cje4QAha\\Y2]V\n`5[.TG~$0'), + ('at%Y)%g5.*vKJ', 'MnucPcE!h;gkhAdI*`Jv$%dafJ'), + ('XKH\\n\'gf4@"6`-', '#~:Nt[^9wtE.4\\@', "9)#qPuEF-A@ -DTE\r= (KgM\\h'i$XU"), + ("<|(h|P9Wz9d9'u,M", '7d-A\nY{}5"\' !*gHHh`x0!B2Ox?yeKb\x0b'), + ('bV?:f\x0b#HDhuwSvys3', ";\r,L![\x0cU7@ne@'?[*&VVI,[}pHM\nB65@LfE16VJPw=r'zU\x0bzWj@"), + ('^|j7N!mV0o(?*1>p?dy', '\\ZdA&:\t\x0b:8\t|7.Kl,oHw-\x0cS\nwZlND~uC@le`Sm'), + ] + for prefix, string in cases: yield lchop_factory(prefix, prefix+string) yield lchop_factory(prefix, string) yield lchop_factory(string, string) yield lchop_factory(string, prefix) yield lchop_factory("", string) - + yield lchop_factory(prefix, "") def partition_factory(iterable, limit, assrt): def test(): @@ -52,6 +80,3 @@ def partition_test_generator(): for iterable, limit, assrt in cases: yield partition_factory(iterable, limit, assrt) - -suite = unittest.TestLoader().loadTestsFromName(__name__) -unittest.TextTestRunner(verbosity=2).run(suite)