You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My test cases had been importing from adjacent modules (from commands import ...), but Pyright didn't love that, so I did the minimum to turn my test folder into a package: added __init__.py and changed relative imports to from .commands import ...). Ward doesn't like this:
ModuleNotFoundError: No module named 'test.commands'
but I noticed it works fine in CI where it's wrapped by coverage:
coverage run -p -m ward
So I checked and see it also works fine if ward is invoked as:
python -m ward
It would be great to have the plain ward invocation work here as well, unless I'm missing something wrong with that.
For reference, this project is here and the change that introduced this problem for ward is:
commit c755f39298e6063377e3debdd3061247aa461cf3
Author: Andy Kluger <[email protected]>
Date: Tue Sep 17 14:17:13 2024 -0400
Make test dir a package for pyright-friendly relative imports
diff --git a/test/__init__.py b/test/__init__.py
new file mode 100644
index 0000000..598d40e
--- /dev/null+++ b/test/__init__.py@@ -0,0 +1 @@+"""Test suite for NestedTextTo."""diff --git a/test/test_json.py b/test/test_json.py
index 6ae29ea..2f3f3dd 100644
--- a/test/test_json.py+++ b/test/test_json.py@@ -2,11 +2,12 @@
from typing import cast
-from commands import json2nt, nt2json
from plumbum import LocalPath, local
-from utils import assert_file_content, casting_args_from_schema_file
from ward import test
+from .commands import json2nt, nt2json+from .utils import assert_file_content, casting_args_from_schema_file+
SAMPLES = local.path(__file__).up() / 'samples' / 'json' # type: ignore
diff --git a/test/test_toml.py b/test/test_toml.py
index 66ab146..aef6551 100644
--- a/test/test_toml.py+++ b/test/test_toml.py@@ -2,11 +2,12 @@
from typing import cast
-from commands import nt2toml, toml2nt
from plumbum import LocalPath, local
-from utils import assert_file_content, casting_args_from_schema_file
from ward import skip, test
+from .commands import nt2toml, toml2nt+from .utils import assert_file_content, casting_args_from_schema_file+
try:
import tomli # noqa: F401
import tomli_w # noqa: F401
diff --git a/test/test_yaml.py b/test/test_yaml.py
index 773e44a..1e64f12 100644
--- a/test/test_yaml.py+++ b/test/test_yaml.py@@ -2,11 +2,12 @@
from typing import cast
-from commands import nt2yaml, yaml2nt
from plumbum import LocalPath, local
-from utils import assert_file_content, casting_args_from_schema_file
from ward import test
+from .commands import nt2yaml, yaml2nt+from .utils import assert_file_content, casting_args_from_schema_file+
SAMPLES = local.path(__file__).up() / 'samples' / 'yaml' # type: ignore
The text was updated successfully, but these errors were encountered:
Copying this from my comment on closed, related, upstream ward issue 152.
My test cases had been importing from adjacent modules (
from commands import ...
), but Pyright didn't love that, so I did the minimum to turn my test folder into a package: added__init__.py
and changed relative imports tofrom .commands import ...
). Ward doesn't like this:but I noticed it works fine in CI where it's wrapped by
coverage
:So I checked and see it also works fine if ward is invoked as:
It would be great to have the plain
ward
invocation work here as well, unless I'm missing something wrong with that.For reference, this project is here and the change that introduced this problem for ward is:
The text was updated successfully, but these errors were encountered: