def time_file(fname): f = open(fname, 'rb') s = common.Sink() t = time.time() parse(f, s) t = time.time() - t print t
def test_rsa_dict_to_key(self): data = open(KEY_FILE_PAIRS[0][0]).read() rsa_dict = top.parse(data) key = top.get_key(rsa_dict) self.assertTrue(key) self.assertTrue(key.e) self.assertTrue(key.d)
def test_x509_dict_to_key(self): data = open(KEY_FILE_PAIRS[0][1]).read() x509_dict = top.parse(data) key = top.get_key(x509_dict) self.assertTrue(key) self.assertTrue(key.e) # "lambda" suppresses exception until called by the test handler self.assertRaises(AttributeError, lambda: key.d)
from __init__ import parse from parse_rcs_file import LoggingSink test_dir = os.path.join(script_dir, 'test-data') filelist = glob.glob(os.path.join(test_dir, '*,v')) filelist.sort() all_tests_ok = 1 for filename in filelist: sys.stderr.write('%s: ' % (filename, )) f = StringIO() try: parse(open(filename, 'rb'), LoggingSink(f)) except Exception, e: sys.stderr.write('Error parsing file: %s!\n' % (e, )) all_tests_ok = 0 else: output = f.getvalue() expected_output_filename = filename[:-2] + '.out' expected_output = open(expected_output_filename, 'rb').read() if output == expected_output: sys.stderr.write('OK\n') else: sys.stderr.write('Output does not match expected output!\n') differ = Differ() for diffline in differ.compare(expected_output.splitlines(1),
def dump_file(fname): parse(open(fname, 'rb'), DumpSink())
class LoggingSink: def __init__(self, f): self.f = f def __getattr__(self, name): return Logger(self.f, name) if __name__ == '__main__': # Since there is nontrivial logic in __init__.py, we have to import # parse() via that file. First make sure that the directory # containing this script is in the path: sys.path.insert(0, os.path.dirname(sys.argv[0])) from __init__ import parse if sys.argv[1:]: for path in sys.argv[1:]: if os.path.isfile(path) and path.endswith(',v'): parse( open(path, 'rb'), LoggingSink(sys.stdout) ) else: sys.stderr.write('%r is being ignored.\n' % path) else: parse(sys.stdin, LoggingSink(sys.stdout))
def setUp(self): with open(KEY_FILE_PAIRS[0][1]) as pub: self.pubkey = top.get_key(top.parse(pub.read())) with open(KEY_FILE_PAIRS[0][0]) as priv: self.privkey = top.get_key(top.parse(priv.read()))
def test_x509_parse(self): self.assertEqual(top.x509_parse, x509_pem.parse) with open(KEY_FILE_PAIRS[0][1]) as d: data = d.read() x509_dict = top.parse(data) self.assertTrue(x509_dict)
def test_x509_parse(self): self.assertEqual(top.x509_parse, x509_pem.parse) data = open(KEY_FILE_PAIRS[0][1]).read() x509_dict = top.parse(data) self.assertTrue(x509_dict)
from __init__ import parse from parse_rcs_file import LoggingSink test_dir = os.path.join(script_dir, 'test-data') filelist = glob.glob(os.path.join(test_dir, '*,v')) filelist.sort() all_tests_ok = 1 for filename in filelist: sys.stderr.write('%s: ' % (filename,)) f = StringIO() try: parse(open(filename, 'rb'), LoggingSink(f)) except Exception, e: sys.stderr.write('Error parsing file: %s!\n' % (e,)) all_tests_ok = 0 else: output = f.getvalue() expected_output_filename = filename[:-2] + '.out' expected_output = open(expected_output_filename, 'rb').read() if output == expected_output: sys.stderr.write('OK\n') else: sys.stderr.write('Output does not match expected output!\n') differ = Differ() for diffline in differ.compare(
self.f.write('%s(%s)\n' % ( self.name, ', '.join(['%r' % arg for arg in args]), )) class LoggingSink: def __init__(self, f): self.f = f def __getattr__(self, name): return Logger(self.f, name) if __name__ == '__main__': # Since there is nontrivial logic in __init__.py, we have to import # parse() via that file. First make sure that the directory # containing this script is in the path: sys.path.insert(0, os.path.dirname(sys.argv[0])) from __init__ import parse if sys.argv[1:]: for path in sys.argv[1:]: if os.path.isfile(path) and path.endswith(',v'): parse(open(path, 'rb'), LoggingSink(sys.stdout)) else: sys.stderr.write('%r is being ignored.\n' % path) else: parse(sys.stdin, LoggingSink(sys.stdout))
def dump_file(fname): parse(open(fname, "rb"), DumpSink())
def setUp(self): self.pubkey = top.get_key(top.parse(open(KEY_FILE_PAIRS[0][1]).read())) self.privkey = top.get_key(top.parse(open(KEY_FILE_PAIRS[0][0]).read()))
def test_rsa_parse(self): self.assertEqual(top.rsa_parse, rsa_pem.parse) with open(KEY_FILE_PAIRS[0][0]) as d: data = d.read() rsa_dict = top.parse(data) self.assertTrue(rsa_dict)
def test_rsa_parse(self): self.assertEqual(top.rsa_parse, rsa_pem.parse) data = open(KEY_FILE_PAIRS[0][0]).read() rsa_dict = top.parse(data) self.assertTrue(rsa_dict)