# set\_tests\_properties ENVIRONMENT ignored

**URL:** https://discourse.cmake.org/t/set-tests-properties-environment-ignored/13425
**Category:** Code
**Tags:** gen:vs, tool:ctest
**Created:** [January 18, 2025, 12:55am UTC](https://discourse.cmake.org/t/set-tests-properties-environment-ignored/13425 "2025-01-18T00:55:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![RobStewart](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@RobStewart](https://discourse.cmake.org/u/RobStewart)
#### Post date: [January 18, 2025, 12:55am UTC](https://discourse.cmake.org/t/set-tests-properties-environment-ignored/13425/1 "2025-01-18T00:55:29Z")

</div>

In my `CMakeLists.txt`, I define a Python unit test like this:

```auto
ADD_TEST(NAME foo
   COMMAND "${python}" -B -m unittest discover -v
   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

```

For that to work, a related `.pyd` must be found from the binary tree. Thus, I specify PYTHONPATH and another needed environment variable, like this:

```auto
SET_TESTS_PROPERTIES(foo PROPERTIES
   ENVIRONMENT "PYTHONPATH=dir1\;dir2;EVAR=false"
)

```

The Python unit tests run, but the PYTHONPATH doesn’t reflect what I set. I tried forward and backslashes in the path, just in case those mattered.

FYI, I’m using the “Visual Studio 15 2017” generator.

What am I missing?

---

<div class="post-metadata">

### Author: ![RobStewart](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@RobStewart](https://discourse.cmake.org/u/RobStewart)
#### Post date: [January 21, 2025, 12:53pm UTC](https://discourse.cmake.org/t/set-tests-properties-environment-ignored/13425/2 "2025-01-21T12:53:47Z")

</div>

Building with makefiles for GCC, the `CTestTestfile.cmake` in the Python extension module directory, which is where the aforementioned `ADD_TEST()` appears, I see the variables defined:

```auto
set_tests_properties(my_tests PROPERTIES ENVIRONMENT "PYTHONPATH=dir1:dir2;EVAR=false" WORKING_DIRECTORY "project source dir")

```

Unfortunately, the tests still fail because the import of the extension module (.so) fails, despite the .so being in `dir1`. (Before you ask, the .so is created before the tests run and the tests fail repeatedly well after the creation of the .so.)
