def test(code): from code import codec, config_parser c = codec.Codec(config_parser.Config()) a = 'Hello, world' b = c.encode(a) assert a == c.decode(b) c.set_alphabet('0123456789') a = '72435' b = c.encode(a) assert a == c.decode(b)
def test(code): from code import codec, parser, generator, config_parser config = config_parser.Config() coder = codec.Codec(config) msg = 'https://www.google.ru/images' encoded = coder.encode(msg) gen = generator.Generator(config) gen.generate(encoded) prs = parser.Parser(config) ret = prs.parse(config.generated_filename + '.png') ret = coder.decode(ret) assert msg == ret
def test(code): from code import codec, parser, generator, config_parser config = config_parser.Config() config.put('apply_mask', False) coder = codec.Codec(config) msg = [False] * 20 + [True] * 20 + [False] * 20 gen = generator.Generator(config) gen.generate(msg) prs = parser.Parser(config) ret = prs.parse(config.generated_filename + '.png') assert len(msg) == len(ret) for i in range(len(msg)): assert msg[i] == ret[i]
def test(code): import os.path from code import config_parser path = os.path.join('resources', 'default.ini') config = config_parser.Config(path)
operation = ('Fparse', args[i + 1]) i += 1 else: print_err( 'Not enough arguments: message is not specified. Aborting.' ) exit() if arg == '-t' or arg == '--test': print('Running tests') tester.test('tests', code) print('Completed.') exit() if arg == '-T' or arg == '--test-draw': config = config_parser.Config(config_file, encoding) gen = generator.Generator(config) gen.generate(None) exit() if arg == '-s' or arg == '--show': show_trigger = True i += 1 if operation == None: print_err('No operation specified. Please, use flags -g, -G or -p') exit() config = config_parser.Config(config_file, encoding) coder = codec.Codec(config)