|
44 | 44 | from tests.standalone import util |
45 | 45 |
|
46 | 46 | is_enabled = 'ENABLE_STANDALONE_UNITTESTS' in os.environ and os.environ['ENABLE_STANDALONE_UNITTESTS'] == "true" |
| 47 | +constraints_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'constraints.txt') |
| 48 | + |
| 49 | +def create_test_env(): |
| 50 | + env = os.environ.copy() |
| 51 | + env["MVN_GRAALPY_VERSION"] = util.get_graalvm_version() |
| 52 | + env["PIP_CONSTRAINT"] = constraints_file |
| 53 | + return env |
47 | 54 |
|
48 | 55 | @unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true") |
49 | 56 | def test_native_executable_one_file(): |
50 | 57 | graalpy = util.get_gp() |
51 | 58 | if graalpy is None: |
52 | 59 | return |
53 | | - env = os.environ.copy() |
54 | | - env["MVN_GRAALPY_VERSION"] = util.get_graalvm_version() |
55 | 60 |
|
| 61 | + env = create_test_env() |
56 | 62 | with tempfile.TemporaryDirectory() as tmpdir: |
57 | 63 |
|
58 | 64 | source_file = os.path.join(tmpdir, "hello.py") |
@@ -80,9 +86,8 @@ def test_native_executable_venv_and_one_file(): |
80 | 86 | graalpy = util.get_gp() |
81 | 87 | if graalpy is None: |
82 | 88 | return |
83 | | - env = os.environ.copy() |
84 | | - env["MVN_GRAALPY_VERSION"] = util.get_graalvm_version() |
85 | 89 |
|
| 90 | + env = create_test_env() |
86 | 91 | with tempfile.TemporaryDirectory() as target_dir: |
87 | 92 | source_file = os.path.join(target_dir, "hello.py") |
88 | 93 | with open(source_file, 'w') as f: |
@@ -123,9 +128,8 @@ def test_native_executable_module(): |
123 | 128 | graalpy = util.get_gp() |
124 | 129 | if graalpy is None: |
125 | 130 | return |
126 | | - env = os.environ.copy() |
127 | | - env["MVN_GRAALPY_VERSION"] = util.get_graalvm_version() |
128 | 131 |
|
| 132 | + env = create_test_env() |
129 | 133 | with tempfile.TemporaryDirectory() as tmp_dir: |
130 | 134 |
|
131 | 135 | module_dir = os.path.join(tmp_dir, "hello_app") |
|
0 commit comments