# Orthanc Test Patch

**URL:** https://discourse.orthanc-server.org/t/orthanc-test-patch/4360
**Category:** General
**Created:** [February 21, 2024, 7:14am UTC](https://discourse.orthanc-server.org/t/orthanc-test-patch/4360 "2024-02-21T07:14:43Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![James](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@James](https://discourse.orthanc-server.org/u/James)
#### Post date: [February 21, 2024, 7:14am UTC](https://discourse.orthanc-server.org/t/orthanc-test-patch/4360/1 "2024-02-21T07:14:43Z")

</div>

Hi Team,

I’ve been having difficulties running the orthanc tests locally on my Mac. I pinpointed the issue with the following:

```python
 subprocess.run(["docker", "compose", "-f", "docker-compose-transfers-concurrency.yml", "down", "-v", "--remove-orphans"], 
                       env= {
                           "ORTHANC_IMAGE_UNDER_TESTS": Helpers.orthanc_under_tests_docker_image
                       },
                       check=True)

```

The issue is that by setting `env=...` this overrides the parent process env, removing required env vars for docker to run correctly. In my case, it leads to “file not found” exceptions.

I would suggest the following

```python
        subprocesss_env = os.environ.copy()
        subprocesss_env["ORTHANC_IMAGE_UNDER_TESTS"] = Helpers.orthanc_under_tests_docker_image
        subprocess.run(["docker", "compose", "-f", "docker-compose-transfers-concurrency.yml", "down", "-v", "--remove-orphans"], 
                       env=subprocesss_env, check=True)

```

Which creates a copy of the current process environment, adds the new var and then calls docker with this env copy. This allows docker to run (at least in my environment).

Hope this helps.

Cheers,

James

---

<div class="post-metadata">

### Author: ![alainmazy](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/alainmazy/32/1576_2.png) [@alainmazy](https://discourse.orthanc-server.org/u/alainmazy)
#### Post date: [February 21, 2024, 7:37am UTC](https://discourse.orthanc-server.org/t/orthanc-test-patch/4360/2 "2024-02-21T07:37:58Z")

</div>

Hi James,

[Patch accepted](https://orthanc.uclouvain.be/hg/orthanc-tests/rev/76c9923050b5) and thanks a lot !

Alain

---

<div class="post-metadata">

### Author: ![James](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@James](https://discourse.orthanc-server.org/u/James)
#### Post date: [February 21, 2024, 9:12am UTC](https://discourse.orthanc-server.org/t/orthanc-test-patch/4360/3 "2024-02-21T09:12:59Z")

</div>

Hi Alain,  
I just ran into the same issue in `test_pg_upgrades.py`. I did a search, but I think this is the last reference to the same pattern.  
James

---

<div class="post-metadata">

### Author: ![alainmazy](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/alainmazy/32/1576_2.png) [@alainmazy](https://discourse.orthanc-server.org/u/alainmazy)
#### Post date: [February 22, 2024, 8:30am UTC](https://discourse.orthanc-server.org/t/orthanc-test-patch/4360/4 "2024-02-22T08:30:29Z")

</div>

Done [here](https://orthanc.uclouvain.be/hg/orthanc-tests/rev/ddf83317c7e0) ✅ .
