Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2017-12-29 22:01:38 +0100
committerArthur de Jong <arthur@arthurdejong.org>2018-02-08 21:09:49 +0100
commit2693495ad3c2ab8d4078d96610295acc9280db7e (patch)
tree54ba194d4c2ee66b63df4a01ee1620c2d4ba75b7
parentfe63c4221abb55610a5348b89341f36be8ca4ff9 (diff)
Fixes to test suite
This ensures that the tests also work without a TTY and work regardless of the PYTHONWARNINGS and TZ environment variables Fixes cd33833
-rw-r--r--tests/test_misc.doctest2
-rw-r--r--tests/test_pskc2csv.doctest17
-rw-r--r--tox.ini1
3 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_misc.doctest b/tests/test_misc.doctest
index 320982b..246ece1 100644
--- a/tests/test_misc.doctest
+++ b/tests/test_misc.doctest
@@ -273,12 +273,14 @@ property.
>>> pskc = PSKC()
>>> key = pskc.add_key()
>>> with warnings.catch_warnings(record=True) as w:
+... warnings.simplefilter('always')
... key.policy.pin_max_failed_attemtps = 10
... assert len(w) == 1
... assert issubclass(w[0].category, DeprecationWarning)
>>> key.policy.pin_max_failed_attempts
10
>>> with warnings.catch_warnings(record=True) as w:
+... warnings.simplefilter('always')
... key.policy.pin_max_failed_attemtps
... assert len(w) == 1
... assert issubclass(w[0].category, DeprecationWarning)
diff --git a/tests/test_pskc2csv.doctest b/tests/test_pskc2csv.doctest
index 38396d9..a97e297 100644
--- a/tests/test_pskc2csv.doctest
+++ b/tests/test_pskc2csv.doctest
@@ -43,6 +43,23 @@ Traceback (most recent call last):
SystemExit: 0
+We hack stdin to lie about being a TTY to ensure the password propmpt are
+always presented.
+
+>>> class TTYFile(object):
+... def __init__(self, f):
+... self.f = f
+...
+... def isatty(self):
+... return True
+...
+... def __getattr__(self, attr):
+... return getattr(self.f, attr)
+>>> sys.stdin = TTYFile(sys.stdin)
+>>> sys.stdin.isatty()
+True
+
+
We can output a CSV file with some columns with the just default arguments.
>>> sys.argv = shlex.split('pskc2csv tests/rfc6030/figure5.pskcxml')
diff --git a/tox.ini b/tox.ini
index b33a31c..7a3e049 100644
--- a/tox.ini
+++ b/tox.ini
@@ -13,6 +13,7 @@ commands = signxml: nosetests
lxml: nosetests --exclude=test_signature.doctest --cover-min-percentage 95
setenv=
PYTHONWARNINGS=all
+ TZ=Europe/Amsterdam
[testenv:flake8]
skip_install = true