From 2693495ad3c2ab8d4078d96610295acc9280db7e Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Fri, 29 Dec 2017 22:01:38 +0100 Subject: 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 --- tests/test_misc.doctest | 2 ++ tests/test_pskc2csv.doctest | 17 +++++++++++++++++ tox.ini | 1 + 3 files changed, 20 insertions(+) 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 -- cgit v1.2.3