Skip to content

Commit

Permalink
added missing imports to autogenerated conftest
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Mar 17, 2024
1 parent 2cedffa commit 25a4a26
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 14 additions & 3 deletions nipype2pydra/task/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class InputsConverter(SpecConverter):
metadata: dict[str, dict[str, Any]], optional
additional metadata to set on any of the input fields (e.g. out_file: position: 1)
"""

callable_defaults: ty.Dict[str, str] = attrs.field(
factory=dict,
converter=default_if_none(factory=dict), # type: ignore
Expand Down Expand Up @@ -403,7 +404,8 @@ class BaseTaskConverter(metaclass=ABCMeta):
converter=from_dict_to_outputs,
)
callables_module: ModuleType = attrs.field(
converter=import_module_from_path, default=None,
converter=import_module_from_path,
default=None,
)
tests: ty.List[TestGenerator] = attrs.field( # type: ignore
factory=list, converter=from_list_to_tests
Expand Down Expand Up @@ -838,7 +840,9 @@ def write_tests(self, filename_test, input_fields, nonstd_types, run=False):
else:
assert len(field) == 3
# Attempt to pick a sensible value for field
trait = self.nipype_interface.input_spec.class_traits()[nm]
trait = self.nipype_interface.input_spec.class_traits()[
nm
]
if isinstance(trait, traits.trait_types.Enum):
value = trait.values[0]
elif isinstance(trait, traits.trait_types.Range):
Expand Down Expand Up @@ -868,7 +872,10 @@ def write_tests(self, filename_test, input_fields, nonstd_types, run=False):
imports = self.construct_imports(
nonstd_types,
spec_str,
base={"import pytest", "from nipype2pydra.testing import PassAfterTimeoutWorker"},
base={
"import pytest",
"from nipype2pydra.testing import PassAfterTimeoutWorker",
},
)
spec_str = "\n".join(imports) + "\n\n" + spec_str

Expand Down Expand Up @@ -946,6 +953,10 @@ def create_doctests(self, input_fields, nonstd_types):
CONFTEST = """
# For debugging in IDE's don't catch raised exceptions and let the IDE
# break at it
import os
import pytest
if os.getenv("_PYTEST_RAISE", "0") != "0":
@pytest.hookimpl(tryfirst=True)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from fileformats.generic import File


class Oned(File):
class OneD(File):
ext = ".1D"
alternate_exts = (".1d",)
binary = True


class Threed(File):
class ThreeD(File):
ext = ".3D"
binary = True

Expand Down

0 comments on commit 25a4a26

Please sign in to comment.