From cba696c4d4335f834e07002722a91a1d67e636c0 Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Fri, 11 Jun 2021 18:10:43 +0100 Subject: [PATCH] tests: run doctests --- jupyter_server/auth/security.py | 10 +++++----- jupyter_server/traittypes.py | 10 ++++++---- pyproject.toml | 6 ++++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/jupyter_server/auth/security.py b/jupyter_server/auth/security.py index 833726d775..4e630c4daa 100644 --- a/jupyter_server/auth/security.py +++ b/jupyter_server/auth/security.py @@ -43,8 +43,8 @@ def passwd(passphrase=None, algorithm='argon2'): Examples -------- - >>> passwd('mypassword') - 'sha1:7cf3:b7d6da294ea9592a9480c8f52e63cd42cfb9dd12' + >>> passwd('mypassword') # doctest: +ELLIPSIS + 'argon2:...' """ if passphrase is None: @@ -94,11 +94,11 @@ def passwd_check(hashed_passphrase, passphrase): Examples -------- - >>> from jupyter_server.auth.security import passwd_check - >>> passwd_check('argon2:...', 'mypassword') + >>> myhash = passwd('mypassword') + >>> passwd_check(myhash, 'mypassword') True - >>> passwd_check('argon2:...', 'otherpassword') + >>> passwd_check(myhash, 'otherpassword') False >>> passwd_check('sha1:0e112c3ddfce:a68df677475c2b47b6e86d0467eec97ac5f4b85a', diff --git a/jupyter_server/traittypes.py b/jupyter_server/traittypes.py index 8e8cb3b3ff..9f31232197 100644 --- a/jupyter_server/traittypes.py +++ b/jupyter_server/traittypes.py @@ -50,13 +50,15 @@ class name where an object was defined. 'an object' >>> describe("a", type(object)) 'a type' + Definite description: - >>> describe("the", object()) - "the object at '0x10741f1b0'" + >>> describe("the", object()) # doctest: +ELLIPSIS + "the object at '0x...'" >>> describe("the", object) - "the type 'object'" + 'the object object' >>> describe("the", type(object)) - "the type 'type'" + 'the type type' + Definitely named description: >>> describe("the", object(), "I made") 'the object I made' diff --git a/pyproject.toml b/pyproject.toml index b46c3a0093..e1a1465f92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,8 +9,10 @@ factory = "jupyter_packaging.npm_builder" ignore = ["tbump.toml", ".*", "*.yml", "package-lock.json", "bootstrap*"] [tool.pytest.ini_options] -# Exclude the example tests. -norecursedirs = "examples/*" +addopts = "--doctest-modules" +testpaths = [ + "jupyter_server" +] [tool.tbump.version] current = "1.9.0.dev0"