Skip to content

Commit

Permalink
NPI-3676 improve robustness of test_sp3_merge() unit test by cleaning…
Browse files Browse the repository at this point in the history
… up pyfakefs, which can persist data between runs
  • Loading branch information
treefern committed Jan 7, 2025
1 parent 77e924e commit a1358e4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/test_sp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,22 @@ class TestMergeSP3(TestCase):
def setUp(self):
self.setUpPyfakefs()

# Not sure if this is helpful
def tearDown(self):
self.tearDownPyfakefs()

def test_sp3merge(self):
# Surprisingly, this reset step must be done explicitly. The fake filesystem is backed by the real one, and
# the temp directory used may retain files from a previous run!
self.fs.reset()

# Create some fake files
file_paths = ["/fake/dir/file1.sp3", "/fake/dir/file2.sp3"]
self.fs.create_file(file_paths[0], contents=input_data)
# Note this fails if the fake file has previously been created in the fakefs (which does actually exist somewhere on the real filesystem)
self.fs.create_file(
file_paths[0],
contents=input_data,
)
self.fs.create_file(file_paths[1], contents=input_data2)

# Call the function to test
Expand Down

0 comments on commit a1358e4

Please sign in to comment.