diff --git a/jaclang/cli/cli.py b/jaclang/cli/cli.py index a932be1af..5feaf6edb 100644 --- a/jaclang/cli/cli.py +++ b/jaclang/cli/cli.py @@ -93,14 +93,14 @@ def run( mod = mod[:-4] jctx = ExecutionContext.create(session=session) - if filename.endswith(".jac"): + JacMachine(base).attach_program(JacProgram(mod_bundle=None, bytecode=None)) + ret_module = jac_import( target=mod, base_path=base, cachable=cache, override_name="__main__" if main else None, - is_origin=True, ) if ret_module is None: @@ -117,7 +117,6 @@ def run( base_path=base, cachable=cache, override_name="__main__" if main else None, - is_origin=True, ) if ret_module is None: loaded_mod = None @@ -129,7 +128,7 @@ def run( if not node or node == "root": entrypoint: Architype = jctx.root.architype - elif obj := jctx.datasource.find_by_id(UUID(node)): + elif obj := jctx.mem.find_by_id(UUID(node)): entrypoint = obj.architype else: print(f"Entrypoint {node} not found.") @@ -145,6 +144,7 @@ def run( print(f"Walker {walker} not found.") jctx.close() + JacMachine.detach() @cmd_registry.register @@ -158,7 +158,7 @@ def get_object(id: str, session: str = "") -> dict: data = {} if id == "root": data = jctx.root.__getstate__() - elif obj := jctx.datasource.find_by_id(UUID(id)): + elif obj := jctx.mem.find_by_id(UUID(id)): data = obj.__getstate__() else: print(f"Object with id {id} not found.") @@ -238,13 +238,15 @@ def enter( base, mod_name = os.path.split(filename) base = base if base else "./" mod_name = mod_name[:-4] - (mod,) = jac_import(target=mod_name, base_path=base, is_origin=True) + (mod,) = jac_import(target=mod_name, base_path=base) + JacMachine(base).attach_program(JacProgram(mod_bundle=None, bytecode=None)) if not mod: print("Errors occurred while importing the module.") else: architype = getattr(mod, entrypoint)(*args) if isinstance(architype, WalkerArchitype): Jac.spawn_call(jctx.entry.architype, architype) + JacMachine.detach() else: print("Not a .jac file.") @@ -391,7 +393,7 @@ def dot( if filename.endswith(".jac"): jac_machine = JacMachine(base) - jac_import(target=mod, base_path=base, is_origin=True) + jac_import(target=mod, base_path=base) module = jac_machine.loaded_modules.get(mod) globals().update(vars(module)) try: diff --git a/jaclang/compiler/tests/test_importer.py b/jaclang/compiler/tests/test_importer.py index c7b630647..135481918 100644 --- a/jaclang/compiler/tests/test_importer.py +++ b/jaclang/compiler/tests/test_importer.py @@ -5,7 +5,7 @@ from jaclang import jac_import from jaclang.cli import cli -from jaclang.runtimelib.machine import JacMachine +from jaclang.runtimelib.machine import JacMachine, JacProgram from jaclang.utils.test import TestCase @@ -14,21 +14,28 @@ class TestLoader(TestCase): def test_import_basic_python(self) -> None: """Test basic self loading.""" - (h,) = jac_import("fixtures.hello_world", base_path=__file__, is_origin=True) + JacMachine(self.fixture_abs_path(__file__)).attach_program( + JacProgram(mod_bundle=None, bytecode=None) + ) + (h,) = jac_import("fixtures.hello_world", base_path=__file__) self.assertEqual(h.hello(), "Hello World!") # type: ignore + JacMachine.detach() def test_modules_correct(self) -> None: """Test basic self loading.""" - jac_machine = JacMachine(__file__) - jac_import("fixtures.hello_world", base_path=__file__, is_origin=True) + JacMachine(self.fixture_abs_path(__file__)).attach_program( + JacProgram(mod_bundle=None, bytecode=None) + ) + jac_import("fixtures.hello_world", base_path=__file__) self.assertIn( "module 'fixtures.hello_world'", - str(jac_machine.loaded_modules), + str(JacMachine.get().loaded_modules), ) self.assertIn( "/tests/fixtures/hello_world.jac", - str(jac_machine.loaded_modules), + str(JacMachine.get().loaded_modules), ) + JacMachine.detach() def test_jac_py_import(self) -> None: """Basic test for pass.""" diff --git a/jaclang/plugin/default.py b/jaclang/plugin/default.py index 5b8fd7127..37cb3190e 100644 --- a/jaclang/plugin/default.py +++ b/jaclang/plugin/default.py @@ -26,7 +26,6 @@ ExecutionContext, GenericEdge, JacTestCheck, - Memory, NodeAnchor, NodeArchitype, Root, @@ -73,24 +72,6 @@ def get_context() -> ExecutionContext: """Get current execution context.""" return ExecutionContext.get() - @staticmethod - @hookimpl - def get_datasource() -> Memory: - """Get current execution context.""" - return ExecutionContext.get().datasource - - @staticmethod - @hookimpl - def get_machine(base_path: str) -> JacMachine: - """Get current execution context.""" - return JacMachine.get(base_path) - - @staticmethod - @hookimpl - def detach_machine() -> None: - """Detach current jac machine.""" - JacMachine.detach() - @staticmethod @hookimpl def make_architype( @@ -250,7 +231,6 @@ def jac_import( lng: Optional[str], items: Optional[dict[str, Union[str, Optional[str]]]], reload_module: Optional[bool], - is_origin: bool, ) -> tuple[types.ModuleType, ...]: """Core Import Process.""" spec = ImportPathSpec( @@ -264,17 +244,16 @@ def jac_import( items, ) - jac_machine = Jac.get_machine(base_path) + jac_machine = JacMachine.get(base_path) if not jac_machine.jac_program: jac_machine.attach_program(JacProgram(mod_bundle=None, bytecode=None)) if lng == "py": - import_result = PythonImporter(jac_machine).run_import(spec) + import_result = PythonImporter(JacMachine.get()).run_import(spec) else: - import_result = JacImporter(jac_machine).run_import(spec, reload_module) - - if is_origin: - Jac.detach_machine() + import_result = JacImporter(JacMachine.get()).run_import( + spec, reload_module + ) return ( (import_result.ret_mod,) diff --git a/jaclang/plugin/feature.py b/jaclang/plugin/feature.py index 24bbef494..a862be7e9 100644 --- a/jaclang/plugin/feature.py +++ b/jaclang/plugin/feature.py @@ -12,14 +12,12 @@ from jaclang.runtimelib.constructs import ( Architype, EdgeArchitype, - Memory, NodeAnchor, NodeArchitype, Root, WalkerArchitype, ) from jaclang.runtimelib.context import ExecutionContext -from jaclang.runtimelib.machine import JacMachine import pluggy @@ -48,21 +46,6 @@ def get_context() -> ExecutionContext: """Get current execution context.""" return pm.hook.get_context() - @staticmethod - def get_datasource() -> Memory: - """Get current execution context.""" - return pm.hook.get_datasource() - - @staticmethod - def get_machine(base_path: str = "") -> JacMachine: - """Get current jac machine.""" - return pm.hook.get_machine(base_path=base_path) - - @staticmethod - def detach_machine() -> None: - """Detach current jac machine.""" - return pm.hook.detach_machine() - @staticmethod def make_architype( cls: type, @@ -121,7 +104,6 @@ def jac_import( lng: Optional[str] = "jac", items: Optional[dict[str, Union[str, Optional[str]]]] = None, reload_module: Optional[bool] = False, - is_origin: bool = False, ) -> tuple[types.ModuleType, ...]: """Core Import Process.""" return pm.hook.jac_import( @@ -134,7 +116,6 @@ def jac_import( lng=lng, items=items, reload_module=reload_module, - is_origin=is_origin, ) @staticmethod diff --git a/jaclang/plugin/spec.py b/jaclang/plugin/spec.py index a0031041d..e230023ba 100644 --- a/jaclang/plugin/spec.py +++ b/jaclang/plugin/spec.py @@ -30,8 +30,6 @@ ) from jaclang.runtimelib.constructs import EdgeArchitype, NodeAnchor, NodeArchitype from jaclang.runtimelib.context import ExecutionContext - from jaclang.runtimelib.machine import JacMachine - from jaclang.runtimelib.memory import Memory import pluggy @@ -50,24 +48,6 @@ def get_context() -> ExecutionContext: """Get current execution context.""" raise NotImplementedError - @staticmethod - @hookspec(firstresult=True) - def get_datasource() -> Memory: - """Get current execution context datasource.""" - raise NotImplementedError - - @staticmethod - @hookspec(firstresult=True) - def get_machine(base_path: str) -> JacMachine: - """Get current jac machine.""" - raise NotImplementedError - - @staticmethod - @hookspec(firstresult=True) - def detach_machine() -> None: - """Detach current jac machine.""" - raise NotImplementedError - @staticmethod @hookspec(firstresult=True) def make_architype( @@ -131,7 +111,6 @@ def jac_import( lng: Optional[str], items: Optional[dict[str, Union[str, Optional[str]]]], reload_module: Optional[bool], - is_origin: bool, ) -> tuple[types.ModuleType, ...]: """Core Import Process.""" raise NotImplementedError diff --git a/jaclang/runtimelib/architype.py b/jaclang/runtimelib/architype.py index c6cd560e5..e6a1111dc 100644 --- a/jaclang/runtimelib/architype.py +++ b/jaclang/runtimelib/architype.py @@ -37,13 +37,13 @@ def save(self) -> None: from jaclang.plugin.feature import JacFeature as Jac self.persistent = True - Jac.get_datasource().set(self.id, self) + Jac.get_context().mem.set(self.id, self) def destroy(self) -> None: """Destroy Anchor.""" from jaclang.plugin.feature import JacFeature as Jac - Jac.get_datasource().remove(self.id) + Jac.get_context().mem.remove(self.id) def is_populated(self) -> bool: """Check if state.""" @@ -61,7 +61,7 @@ def populate(self) -> None: """Retrieve the Architype from db and return.""" from jaclang.plugin.feature import JacFeature as Jac - jsrc = Jac.get_datasource() + jsrc = Jac.get_context().mem if anchor := jsrc.find_by_id(self.id): self.__dict__.update(anchor.__dict__) @@ -245,7 +245,7 @@ def destroy(self) -> None: for edge in self.edges: edge.destroy() - Jac.get_datasource().remove(self.id) + Jac.get_context().mem.remove(self.id) def __getstate__(self) -> dict[str, object]: """Serialize Node Anchor.""" @@ -285,7 +285,7 @@ def destroy(self) -> None: from jaclang.plugin.feature import JacFeature as Jac self.detach() - Jac.get_datasource().remove(self.id) + Jac.get_context().mem.remove(self.id) def __getstate__(self) -> dict[str, object]: """Serialize Node Anchor.""" diff --git a/jaclang/runtimelib/context.py b/jaclang/runtimelib/context.py index e4c308c3e..e24d58c1c 100644 --- a/jaclang/runtimelib/context.py +++ b/jaclang/runtimelib/context.py @@ -24,7 +24,7 @@ class ExecutionContext: """Execution Context.""" - datasource: Memory + mem: Memory reports: list[Any] system_root: NodeAnchor root: NodeAnchor @@ -37,7 +37,7 @@ def generate_system_root(self) -> NodeAnchor: id=UUID(SUPER_ROOT_UUID), architype=architype, persistent=True, edges=[] ) architype.__jac__ = anchor - self.datasource.set(anchor.id, anchor) + self.mem.set(anchor.id, anchor) return anchor def init_anchor( @@ -47,14 +47,14 @@ def init_anchor( ) -> NodeAnchor: """Load initial anchors.""" if anchor_id and isinstance( - anchor := self.datasource.find_by_id(UUID(anchor_id)), NodeAnchor + anchor := self.mem.find_by_id(UUID(anchor_id)), NodeAnchor ): return anchor return default() if callable(default) else default def close(self) -> None: """Close current ExecutionContext.""" - self.datasource.close() + self.mem.close() EXECUTION_CONTEXT.set(None) @staticmethod @@ -66,7 +66,7 @@ def create( ) -> ExecutionContext: """Create ExecutionContext.""" ctx = ExecutionContext() - ctx.datasource = ShelfStorage(session) + ctx.mem = ShelfStorage(session) ctx.reports = [] ctx.system_root = ctx.init_anchor(SUPER_ROOT_UUID, ctx.generate_system_root) ctx.root = ctx.init_anchor(root, ctx.system_root) diff --git a/jaclang/tests/fixtures/foo.jac b/jaclang/tests/fixtures/foo.jac index 4f288f844..4b3d756cf 100644 --- a/jaclang/tests/fixtures/foo.jac +++ b/jaclang/tests/fixtures/foo.jac @@ -1,44 +1,43 @@ import:py from jaclang.plugin.feature, JacFeature as Jac; +import:py from jaclang.runtimelib.machine, JacMachine; import:jac from bar, bar_walk; - - # Test runner to initialize the walker + can test_run { # Print the loaded modules - modules = Jac.get_machine().list_modules(); + modules = JacMachine.get().list_modules(); "Loaded Modules:" |> print; for mod_name in modules { f"Module: {mod_name}" |> print; } # Print walkers - walkers = Jac.get_machine().list_walkers(mod_name); - if walkers{ - f"Walkers in {mod_name}:" |> print; - for walker in walkers{ - f" - Walker: {walker}" |> print; - } + walkers = JacMachine.get().list_walkers(mod_name); + if walkers { + f"Walkers in {mod_name}:" |> print; + for walker in walkers { + f" - Walker: {walker}" |> print; } - + } # Print nodes - nodes = Jac.get_machine().list_nodes(mod_name); - if nodes{ + nodes = JacMachine.get().list_nodes(mod_name); + if nodes { f"Nodes in {mod_name}:" |> print; - for node in nodes{ + for node in nodes { f" - Node: {node}" |> print; } } # Print edges - edges = Jac.get_machine().list_edges(mod_name); - if edges{ + edges = JacMachine.get().list_edges(mod_name); + if edges { f"Edges in {mod_name}:" |> print; - for edge in edges{ + for edge in edges { f" - Edge: {edge}" |> print; } } root spawn bar_walk(); } - # Define the entry point to run the test + with entry { test_run(); } diff --git a/jaclang/tests/test_language.py b/jaclang/tests/test_language.py index 39a702326..99d77400f 100644 --- a/jaclang/tests/test_language.py +++ b/jaclang/tests/test_language.py @@ -13,7 +13,7 @@ from jaclang.compiler.compile import jac_file_to_pass, jac_pass_to_pass, jac_str_to_pass from jaclang.compiler.passes.main.schedules import py_code_gen_typed from jaclang.runtimelib.context import SUPER_ROOT_ANCHOR -from jaclang.runtimelib.machine import JacMachine +from jaclang.runtimelib.machine import JacMachine, JacProgram from jaclang.utils.test import TestCase @@ -23,8 +23,16 @@ class JacLanguageTests(TestCase): def setUp(self) -> None: """Set up test.""" SUPER_ROOT_ANCHOR.edges.clear() + JacMachine(self.fixture_abs_path("./")).attach_program( + JacProgram(mod_bundle=None, bytecode=None) + ) return super().setUp() + def tearDown(self) -> None: + """Tear down test.""" + JacMachine.detach() + return super().tearDown() + def test_sub_abilities(self) -> None: """Basic test for pass.""" captured_output = io.StringIO() @@ -63,9 +71,7 @@ def test_simple_jac_red(self) -> None: """Parse micro jac file.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "micro.simple_walk", base_path=self.examples_abs_path(""), is_origin=True - ) + jac_import("micro.simple_walk", base_path=self.examples_abs_path("")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual( @@ -78,7 +84,7 @@ def test_guess_game(self) -> None: """Parse micro jac file.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("guess_game", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("guess_game", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual( @@ -90,9 +96,7 @@ def test_chandra_bugs(self) -> None: """Parse micro jac file.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "chandra_bugs", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("chandra_bugs", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual( @@ -104,9 +108,7 @@ def test_chandra_bugs2(self) -> None: """Parse micro jac file.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "chandra_bugs2", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("chandra_bugs2", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual( @@ -121,7 +123,7 @@ def test_ignore(self) -> None: """Parse micro jac file.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("ignore_dup", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("ignore_dup", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual(stdout_value.split("\n")[0].count("here"), 10) @@ -131,9 +133,7 @@ def test_dataclass_hasability(self) -> None: """Parse micro jac file.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "hashcheck_dup", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("hashcheck_dup", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual(stdout_value.count("check"), 2) @@ -152,9 +152,7 @@ def test_need_import(self) -> None: """Test importing python.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "needs_import", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("needs_import", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn(" None: """Test the dot gen of nodes and edges of bubblesort.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "gendot_bubble_sort", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("gendot_bubble_sort", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn( @@ -189,9 +185,7 @@ def test_assign_compr(self) -> None: """Test assign_compr.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "assign_compr_dup", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("assign_compr_dup", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual( @@ -203,7 +197,7 @@ def test_semstr(self) -> None: """Test semstring.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("semstr", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("semstr", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertNotIn("Error", stdout_value) @@ -212,9 +206,7 @@ def test_raw_bytestr(self) -> None: """Test raw string and byte string.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "raw_byte_string", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("raw_byte_string", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual(stdout_value.count(r"\\\\"), 2) @@ -225,7 +217,7 @@ def test_deep_imports(self) -> None: captured_output = io.StringIO() sys.stdout = captured_output - jac_import("deep_import", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("deep_import", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual(stdout_value.split("\n")[0], "one level deeperslHello World!") @@ -242,11 +234,8 @@ def test_deep_imports_mods(self) -> None: for i in targets: if i in sys.modules: del sys.modules[i] - jac_machine = JacMachine(self.fixture_abs_path("./")) - jac_import( - "deep_import_mods", base_path=self.fixture_abs_path("./"), is_origin=True - ) - mods = jac_machine.loaded_modules.keys() + jac_import("deep_import_mods", base_path=self.fixture_abs_path("./")) + mods = JacMachine.get().loaded_modules.keys() for i in targets: self.assertIn(i, mods) self.assertEqual(len([i for i in mods if i.startswith("deep")]), 6) @@ -256,9 +245,7 @@ def test_deep_outer_imports_one(self) -> None: captured_output = io.StringIO() sys.stdout = captured_output jac_import( - "deep.deeper.deep_outer_import", - base_path=self.fixture_abs_path("./"), - is_origin=True, + "deep.deeper.deep_outer_import", base_path=self.fixture_abs_path("./") ) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() @@ -292,9 +279,7 @@ def test_has_lambda_goodness(self) -> None: """Test has lambda_goodness.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "has_goodness", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("has_goodness", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual(stdout_value.split("\n")[0], "mylist: [1, 2, 3]") @@ -304,7 +289,7 @@ def test_conn_assign_on_edges(self) -> None: """Test conn assign on edges.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("edge_ops", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("edge_ops", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn("[(3, 5), (14, 1), (5, 1)]", stdout_value) @@ -315,7 +300,7 @@ def test_disconnect(self) -> None: """Test conn assign on edges.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("disconn", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("disconn", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue().split("\n") self.assertIn("c(cc=0)", stdout_value[0]) @@ -332,9 +317,7 @@ def test_simple_archs(self) -> None: """Test conn assign on edges.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "simple_archs", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("simple_archs", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual(stdout_value.split("\n")[0], "1 2 0") @@ -344,7 +327,7 @@ def test_edge_walk(self) -> None: """Test walking through edges.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("edges_walk", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("edges_walk", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn("creator()\n", stdout_value) @@ -357,7 +340,7 @@ def test_impl_grab(self) -> None: """Test walking through edges.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("impl_grab", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("impl_grab", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn("1.414", stdout_value) @@ -366,7 +349,7 @@ def test_tuple_of_tuple_assign(self) -> None: """Test walking through edges.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("tuplytuples", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("tuplytuples", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn( @@ -378,9 +361,7 @@ def test_deferred_field(self) -> None: """Test walking through edges.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "deferred_field", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("deferred_field", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn( @@ -392,9 +373,7 @@ def test_gen_dot_builtin(self) -> None: """Test the dot gen of nodes and edges as a builtin.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "builtin_dotgen", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("builtin_dotgen", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual(stdout_value.count("True"), 14) @@ -403,9 +382,7 @@ def test_with_contexts(self) -> None: """Test walking through edges.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "with_context", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("with_context", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn("im in", stdout_value) @@ -420,11 +397,7 @@ def test_typed_filter_compr(self) -> None: """Parse micro jac file.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "micro.typed_filter_compr", - base_path=self.examples_abs_path(""), - is_origin=True, - ) + jac_import("micro.typed_filter_compr", base_path=self.examples_abs_path("")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn( @@ -438,9 +411,7 @@ def test_edge_node_walk(self) -> None: """Test walking through edges and nodes.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "edge_node_walk", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("edge_node_walk", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn("creator()\n", stdout_value) @@ -459,7 +430,7 @@ def test_impl_decl_resolution_fix(self) -> None: """Test walking through edges and nodes.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("mtest", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("mtest", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn("2.0\n", stdout_value) @@ -468,7 +439,7 @@ def test_registry(self) -> None: """Test Jac registry feature.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("registry", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("registry", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertNotIn("Error", stdout_value) @@ -491,11 +462,7 @@ def test_enum_inside_arch(self) -> None: """Test Enum as member stmt.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "enum_inside_archtype", - base_path=self.fixture_abs_path("./"), - is_origin=True, - ) + jac_import("enum_inside_archtype", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual("2\n", stdout_value) @@ -522,9 +489,7 @@ def test_needs_import_1(self) -> None: self.assertEqual(len(ir.get_all_sub_nodes(ast.Architype)), 7) captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "needs_import_1", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("needs_import_1", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn("pyfunc_1 imported", stdout_value) @@ -584,9 +549,7 @@ def test_needs_import_2(self) -> None: ) # Because of the Architype from math captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "needs_import_2", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("needs_import_2", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn("pyfunc_2 imported", stdout_value) @@ -634,9 +597,7 @@ def test_needs_import_3(self) -> None: ) # Because of the Architype from other imports captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "needs_import_3", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("needs_import_3", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn("pyfunc_3 imported", stdout_value) @@ -701,9 +662,7 @@ def test_inherit_check(self) -> None: """Test py ast to Jac ast conversion output.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "inherit_check", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("inherit_check", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual("I am in b\nI am in b\nwww is also in b\n", stdout_value) @@ -712,7 +671,7 @@ def test_tuple_unpack(self) -> None: """Test tuple unpack.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("tupleunpack", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("tupleunpack", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue().split("\n") self.assertIn("1", stdout_value[0]) @@ -722,7 +681,7 @@ def test_try_finally(self) -> None: """Test try finally.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("try_finally", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("try_finally", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue().split("\n") self.assertIn("try block", stdout_value[0]) @@ -735,9 +694,7 @@ def test_arithmetic_bug(self) -> None: """Test arithmetic bug.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "arithmetic_bug", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("arithmetic_bug", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue().split("\n") self.assertEqual("0.0625", stdout_value[0]) @@ -750,7 +707,7 @@ def test_lambda_expr(self) -> None: """Test lambda expr.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("lambda", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("lambda", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue().split("\n") self.assertEqual("9", stdout_value[0]) @@ -829,9 +786,7 @@ def test_deep_convert(self) -> None: self.assertEqual(len(ir.get_all_sub_nodes(ast.SubNodeList)), 269) captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "deep_convert", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("deep_convert", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn("Deep convo is imported", stdout_value) @@ -840,9 +795,7 @@ def test_override_walker_inherit(self) -> None: """Test py ast to Jac ast conversion output.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "walker_override", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("walker_override", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual("baz\nbar\n", stdout_value) @@ -878,7 +831,7 @@ def test_self_with_no_sig(self) -> None: # we can get rid of this, isn't? """Test py ast to Jac ast conversion output.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("nosigself", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("nosigself", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual(stdout_value.count("5"), 2) @@ -887,9 +840,7 @@ def test_hash_init_check(self) -> None: # we can get rid of this, isn't? """Test py ast to Jac ast conversion output.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "hash_init_check", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("hash_init_check", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn("Test Passed", stdout_value) @@ -938,9 +889,7 @@ def test_edge_expr_not_type(self) -> None: """Test importing python.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "edgetypeissue", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("edgetypeissue", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn("[x()]", stdout_value) @@ -949,9 +898,7 @@ def test_blank_with_entry(self) -> None: """Test importing python.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import( - "blankwithentry", base_path=self.fixture_abs_path("./"), is_origin=True - ) + jac_import("blankwithentry", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertIn("i work", stdout_value) @@ -960,7 +907,7 @@ def test_double_import_exec(self) -> None: """Test importing python.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("dblhello", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("dblhello", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue() self.assertEqual(stdout_value.count("Hello World!"), 1) @@ -970,7 +917,7 @@ def test_cls_method(self) -> None: """Test class method output.""" captured_output = io.StringIO() sys.stdout = captured_output - jac_import("cls_method", base_path=self.fixture_abs_path("./"), is_origin=True) + jac_import("cls_method", base_path=self.fixture_abs_path("./")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue().split("\n") self.assertEqual("MyClass", stdout_value[0]) @@ -982,7 +929,7 @@ def test_list_methods(self) -> None: captured_output = io.StringIO() sys.stdout = captured_output - jac_import("foo", base_path=self.fixture_abs_path("."), is_origin=True) + jac_import("foo", base_path=self.fixture_abs_path(".")) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue()