From c1abf1b4928eb6df9bbaff3f118bde45c3d4a5a3 Mon Sep 17 00:00:00 2001 From: BLUELOVETH Date: Thu, 1 Jun 2023 00:43:24 +0800 Subject: [PATCH] ... --- src/main.cpp | 2 +- tests/30_import.py | 4 ++-- tests/test1/__init__.py | 1 + tests/test1/_a.py | 4 ++++ tests/test1/_b.py | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 tests/test1/__init__.py create mode 100644 tests/test1/_a.py create mode 100644 tests/test1/_b.py diff --git a/src/main.cpp b/src/main.cpp index 891008b5..a546509e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,7 +46,7 @@ int main(int argc, char** argv){ std::filesystem::current_path(filepath.parent_path()); pkpy::PyObject* ret = nullptr; - ret = vm->exec(src.c_str(), argv_1, pkpy::EXEC_MODE); + ret = vm->exec(src.c_str(), filepath.filename().string(), pkpy::EXEC_MODE); pkpy_delete(vm); return ret != nullptr ? 0 : 1; } diff --git a/tests/30_import.py b/tests/30_import.py index 21c01aa4..112cc69c 100644 --- a/tests/30_import.py +++ b/tests/30_import.py @@ -1,3 +1,3 @@ -import test +import test1 -assert test.add(1, 2) == 13 \ No newline at end of file +assert test1.add(1, 2) == 13 \ No newline at end of file diff --git a/tests/test1/__init__.py b/tests/test1/__init__.py new file mode 100644 index 00000000..35563054 --- /dev/null +++ b/tests/test1/__init__.py @@ -0,0 +1 @@ +from ._a import add \ No newline at end of file diff --git a/tests/test1/_a.py b/tests/test1/_a.py new file mode 100644 index 00000000..cc4bbede --- /dev/null +++ b/tests/test1/_a.py @@ -0,0 +1,4 @@ +from ._b import C + +def add(a, b): + return a + b + C \ No newline at end of file diff --git a/tests/test1/_b.py b/tests/test1/_b.py new file mode 100644 index 00000000..d05bf87d --- /dev/null +++ b/tests/test1/_b.py @@ -0,0 +1 @@ +from test2 import D as C \ No newline at end of file