Skip to content

Commit

Permalink
Use setUpClass() from unittest
Browse files Browse the repository at this point in the history
for expensive operations such as downloads or initializing large
objects.
  • Loading branch information
jmlapre committed Dec 12, 2024
1 parent 1328571 commit 7ef7dee
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/sst/elements/cramSim/tests/testsuite_default_cramSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import os
import shutil
import tempfile


class testcase_cramSim_Component(SSTTestCase):
Expand All @@ -13,6 +14,23 @@ def setUp(self):
super(type(self), self).setUp()
self._setupcramSimTestFiles()

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.downloadFiles()

@classmethod
def downloadFiles(cls):
# create a temp directory
tempdir = tempfile.mkdtemp()

# wget a test file tar.gz
testfile = "sst-cramSim_trace_verimem_trace_files.tar.gz"
fileurl = "https://github.com/sstsimulator/sst-downloads/releases/download/TestFiles/{0}".format(testfile)
cls.assertTrue(os_wget(fileurl, tempdir), "Failed to download {0}".format(testfile))

cls.download_file = f"{tempdir}/{testfile}"

def tearDown(self):
# Put test based teardown code here. it is called once after every test
super(type(self), self).tearDown()
Expand Down Expand Up @@ -137,12 +155,5 @@ def _setupcramSimTestFiles(self):
for f in os.listdir(self.cramSimElementTestsDir):
os_symlink_file(self.cramSimElementTestsDir, self.testcramSimTestsDir, f)

# wget a test file tar.gz
testfile = "sst-cramSim_trace_verimem_trace_files.tar.gz"
fileurl = "https://github.com/sstsimulator/sst-downloads/releases/download/TestFiles/{0}".format(testfile)
self.assertTrue(os_wget(fileurl, self.testcramSimTestsDir), "Failed to download {0}".format(testfile))

# Extract the test file
filename = "{0}/{1}".format(self.testcramSimTestsDir, testfile)
os_extract_tar(filename, self.testcramSimTestsDir)

os_extract_tar(self.__class__.download_file, self.testcramSimTestsDir)

0 comments on commit 7ef7dee

Please sign in to comment.