Skip to content

Commit

Permalink
Add test for missing file on directory changers retrieval.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakehader committed Apr 22, 2022
1 parent d522ed0 commit c931d30
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions armi/utils/tests/test_directoryChangers.py
Expand Up @@ -142,3 +142,19 @@ def f(name):
self.assertTrue(os.path.exists(f("file2.txt")))
os.remove(f("file1.txt"))
os.remove(f("file2.txt"))

def test_file_retrieval_missing_file(self):
"""Tests that the directory changer still returns a subset of files even if all do not exist."""

def f(name):
"""Utility to avoid test clashes during cleanups"""
return self._testMethodName + name

with directoryChangers.TemporaryDirectoryChanger(
filesToRetrieve=[f("file1.txt"), f("file2.txt")]
):
Path(f("file1.txt")).touch()

self.assertTrue(os.path.exists(f("file1.txt")))
self.assertFalse(os.path.exists(f("file2.txt")))
os.remove(f("file1.txt"))

0 comments on commit c931d30

Please sign in to comment.