Skip to content

Commit

Permalink
Remove temporary directories after test done (#6236)
Browse files Browse the repository at this point in the history
* remove temporary isolated venv after isolated notebook/packaging test done

* remove temporary venv after cloned env test done

* remove temporary directories for figures after heatmap testings

Fixes #6036
  • Loading branch information
shawn-peng committed Aug 18, 2023
1 parent 30fa6f5 commit 95cb43f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cirq-core/cirq/vis/heatmap_test.py
Expand Up @@ -14,6 +14,7 @@
"""Tests for Heatmap."""

import pathlib
import shutil
import string
from tempfile import mkdtemp

Expand Down Expand Up @@ -309,6 +310,7 @@ def test_colorbar(ax, position, size, pad):

plt.close(fig1)
plt.close(fig2)
shutil.rmtree(tmp_dir)


@pytest.mark.usefixtures('closefigures')
Expand Down
2 changes: 2 additions & 0 deletions dev_tools/cloned_env_test.py
Expand Up @@ -15,6 +15,7 @@
"""Tests the cloned_env fixture in conftest.py"""
import json
import os
import shutil
import subprocess
from unittest import mock

Expand All @@ -39,3 +40,4 @@ def test_isolated_env_cloning(cloned_env, param):
packages = json.loads(result.stdout)
assert {"name": "flynt", "version": "0.64"} in packages
assert {"astor", "flynt", "pip", "setuptools", "wheel"} == set(p['name'] for p in packages)
shutil.rmtree(env)
2 changes: 2 additions & 0 deletions dev_tools/notebooks/isolated_notebook_test.py
Expand Up @@ -27,6 +27,7 @@
import os
import re
import subprocess
import shutil
import warnings
from typing import Set, List

Expand Down Expand Up @@ -188,6 +189,7 @@ def _rewrite_and_run_notebook(notebook_path, cloned_env):
f"dev_tools/notebooks/isolated_notebook_test.py."
)
os.remove(rewritten_notebook_path)
shutil.rmtree(notebook_env)


@pytest.mark.slow
Expand Down
2 changes: 2 additions & 0 deletions dev_tools/packaging/isolated_packages_test.py
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
import shutil
import subprocess
from unittest import mock

Expand Down Expand Up @@ -48,3 +49,4 @@ def test_isolated_packages(cloned_env, module):
check=False,
)
assert result.returncode == 0, f"Failed isolated tests for {module.name}:\n{result.stdout}"
shutil.rmtree(env)

0 comments on commit 95cb43f

Please sign in to comment.