Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/test_write.doctest
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2015-10-06 22:50:37 +0200
committerArthur de Jong <arthur@arthurdejong.org>2015-10-06 23:39:18 +0200
commit671b6e2a751322ceb19b324041c78d856ec53d26 (patch)
tree12915831cc37f267b4f6c8ca0fc17189725f769c /tests/test_write.doctest
parent68b20e272d5546c94bffd90002732a55696f8978 (diff)
Support Python 3
This enables support for Python 3 together with Python 2 support with a single codebase. On Python 3 key data is passed around as bytestrings which makes the doctests a little harder to maintain across Python versions.
Diffstat (limited to 'tests/test_write.doctest')
-rw-r--r--tests/test_write.doctest12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/test_write.doctest b/tests/test_write.doctest
index 0d91eb6..7dc585e 100644
--- a/tests/test_write.doctest
+++ b/tests/test_write.doctest
@@ -1,6 +1,6 @@
test_write.doctest - tests for writing PSKC files
-Copyright (C) 2014 Arthur de Jong
+Copyright (C) 2014-2015 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,14 +17,16 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
+
+>>> from pskc import PSKC
+
>>> import datetime
>>> import sys
>>> import tempfile
+>>> from binascii import a2b_hex
>>> from dateutil.tz import tzutc
>>> utc = tzutc()
->>> from pskc import PSKC
-
Build a PSKC structure.
@@ -57,7 +59,7 @@ Add a key with all attributes set.
>>> key.response_length = 8
>>> key.response_check = False
>>> key.counter = 0
->>> key.secret = '4e1790ba272406ba309c5a31'.decode('hex')
+>>> key.secret = a2b_hex('4e1790ba272406ba309c5a31')
Add policy information and a PIN.
@@ -83,7 +85,7 @@ argument).
>>> f = tempfile.NamedTemporaryFile()
>>> pskc.write(f.name)
->>> sys.stdout.write(open(f.name, 'rb').read())
+>>> x = sys.stdout.write(open(f.name, 'r').read())
<?xml version="1.0" encoding="UTF-8"?>
<pskc:KeyContainer Version="1.0" xmlns:pskc="urn:ietf:params:xml:ns:keyprov:pskc">
<pskc:KeyPackage>