Skip to content

Commit

Permalink
Make tests thread-safe.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbkalmbach committed Mar 2, 2021
1 parent 018e461 commit 333f899
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
13 changes: 13 additions & 0 deletions python/lsst/ts/wep/CreatePhosimDonutTemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ def __init__(self):
# The location where we will store the final templates
self.templateDestDir = os.path.join(self.templateDataPath, "phosimTemplates")

def setTempWorkPaths(self, newBasePath):
"""
Point to a new temporary work directory. Update work repo as well.
Parameters
----------
newBasePath : str
New location of temporary work directories.
"""

self.tempWorkPath = newBasePath
self.repoDir = os.path.join(self.tempWorkPath, 'input')

def createWorkDirectories(self):
"""
Create the final template directory as well as
Expand Down
9 changes: 5 additions & 4 deletions tests/test_createPhosimDonutTemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import unittest
import os
import shutil
import tempfile
import numpy as np

from lsst.ts.wep.CreatePhosimDonutTemplates import CreatePhosimDonutTemplates
Expand All @@ -41,9 +42,9 @@ def setUp(self):
# Location where templates are created
self.templateDir = os.path.join(self.templateDataDir, "phosimTemplates")
# Temporary work directory
self.tempWorkDir = os.path.join(self.templateDataDir, "tempDir")
# Make the temporary directory for all tests
os.mkdir(self.tempWorkDir)
self.tempTestDirectory = tempfile.TemporaryDirectory()
self.tempWorkDir = self.tempTestDirectory.name
self.createPhosimDonuts.setTempWorkPaths(self.tempWorkDir)

def tearDown(self):

Expand All @@ -54,7 +55,7 @@ def tearDown(self):
pass

# Remove work directory in case of clean up method test failure
shutil.rmtree(self.tempWorkDir)
self.tempTestDirectory.cleanup()

def _copyPhosimFiles(self):

Expand Down

0 comments on commit 333f899

Please sign in to comment.