Skip to content

Commit 42128ee

Browse files
committed
Fixed test coverage
1 parent e6e30ae commit 42128ee

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

codext/base/base45.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
__examples__ = {
1515
'enc(base45|base-45|base_45)': {'this is a test!': "AWE+EDH44.OEOCC7WE QEX0"},
16-
'dec(base45)': {'BAD STRING\00': None},
16+
'dec(base45)': {'BAD STRING\00': None, 'AWE+EDH44.OEOCC7WE QEX000': None},
1717
}
1818
__guess__ = ["base45", "base45-inv"]
1919

tests/test_base.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
"""Base codecs tests.
44
55
"""
6+
import os
7+
import sys
68
from unittest import TestCase
79

810
from codext.__common__ import *
911
from codext.base._base import _generate_charset
10-
from codext.base.baseN import base
12+
from codext.base.baseN import base, main2, main32, main64url
1113

1214

1315
class TestCodecsBase(TestCase):
@@ -238,4 +240,17 @@ def test_codec_base_generic(self):
238240
self.assertRaises(LookupError, codecs.decode, "test", "base0-generic")
239241
self.assertRaises(LookupError, codecs.decode, "test", "base1-generic")
240242
self.assertRaises(LookupError, codecs.decode, "test", "base256-generic")
243+
244+
def test_base_main(self):
245+
tmp = sys.argv[:]
246+
tfile = "test-base-main.txt"
247+
with open(tfile, 'w') as f:
248+
f.write("This is a long test string for the sake of causing line wrapping based on default parameters.")
249+
sys.argv = [tmp[0], tfile]
250+
for m in main32, main64url:
251+
self.assertEqual(m(), 0)
252+
sys.argv = [tmp[0], tfile, "-d"]
253+
self.assertEqual(main2(), 1)
254+
os.remove(tfile)
255+
sys.argv[:] = tmp
241256

tests/test_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ def test_guess_decode(self):
150150
self.assertIn("F1@9", _l(codext.guess("VGVzdCBGMUA5ICE=", codext.stopfunc.flag, max_depth=1, stop=False,
151151
show=True)))
152152
self.assertEqual(len(codext.guess("VGhpcyBpcyBhIHRlc3Q=", " a test", max_depth=1, codec_categories="base",
153-
exclude="base64")), 0)
153+
exclude=("base64", "base64-url"))), 0)
154154
self.assertEqual(len(codext.guess("VGhpcyBpcyBhIHRlc3Q=", " a test", max_depth=1, codec_categories="base",
155-
scoring_heuristic=True, exclude=("base64", "atbash"))), 0)
155+
scoring_heuristic=True, exclude=("base64", "base64-url", "atbash"))), 0)
156156
self.assertRaises(ValueError, codext.guess, STR, max_depth=0)
157157
self.assertRaises(ValueError, codext.guess, STR, exclude=42)
158158
for c in ["base", "language", "native", "stegano"]:

0 commit comments

Comments
 (0)