From 8ce42ad9ebff5833650b87d282404db9738aab18 Mon Sep 17 00:00:00 2001 From: Jan Wille Date: Thu, 28 Jul 2022 20:39:52 +0200 Subject: [PATCH] import key submodule into __init__ fixes #87 --- readchar/__init__.py | 2 ++ readchar/key.py | 2 ++ tests/posix/test_import.py | 1 - tests/windows/test_import.py | 1 - 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/readchar/__init__.py b/readchar/__init__.py index 64817a1..8ba31da 100644 --- a/readchar/__init__.py +++ b/readchar/__init__.py @@ -12,7 +12,9 @@ or platform.startswith("freebsd") ): from ._posix_read import readchar, readkey + from . import _posix_key as key elif platform in ("win32", "cygwin"): from ._win_read import readchar, readkey + from . import _win_key as key else: raise NotImplementedError(f"The platform {platform} is not supported yet") diff --git a/readchar/key.py b/readchar/key.py index a73163a..0e83a2a 100644 --- a/readchar/key.py +++ b/readchar/key.py @@ -1,4 +1,6 @@ # flake8: noqa E401,E403 +# this file exists only for backwards compatability +# it allow the use of `import readchar.key` from . import platform diff --git a/tests/posix/test_import.py b/tests/posix/test_import.py index 4c858e5..0dde25d 100644 --- a/tests/posix/test_import.py +++ b/tests/posix/test_import.py @@ -11,6 +11,5 @@ def test_readkeyImport(): def test_keyImport(): a = {k: v for k, v in vars(readchar.key).items() if not k.startswith("__")} - del a["platform"] b = {k: v for k, v in vars(readchar._posix_key).items() if not k.startswith("__")} assert a == b diff --git a/tests/windows/test_import.py b/tests/windows/test_import.py index 2d762d3..4b52d33 100644 --- a/tests/windows/test_import.py +++ b/tests/windows/test_import.py @@ -11,6 +11,5 @@ def test_readkeyImport(): def test_keyImport(): a = {k: v for k, v in vars(readchar.key).items() if not k.startswith("__")} - del a["platform"] b = {k: v for k, v in vars(readchar._win_key).items() if not k.startswith("__")} assert a == b