aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Ionite <[email protected]>2023-03-09 20:26:00 -0500
committerGravatar Ionite <[email protected]>2023-03-09 20:26:00 -0500
commit9b31db9291b9bb4147eede842ae876e7b8cdd6b2 (patch)
tree0cabd781771862e300861c55112c2b9a8f73465f
parentAdd files output exclude for hidden paths (diff)
Add unit test for hidden paths exclusion
-rw-r--r--tests/test_nsjail.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_nsjail.py b/tests/test_nsjail.py
index cad79f3..456046b 100644
--- a/tests/test_nsjail.py
+++ b/tests/test_nsjail.py
@@ -170,6 +170,25 @@ class NsJailTests(unittest.TestCase):
self.assertIn("No space left on device", result.stdout)
self.assertEqual(result.stderr, None)
+ def test_write_hidden_exclude(self):
+ """Hidden paths should be excluded from output."""
+ code = dedent(
+ """
+ from pathlib import Path
+
+ Path("normal").mkdir()
+ Path("normal/a.txt").write_text("a")
+ Path("normal/.hidden.txt").write_text("a")
+ Path(".hidden").mkdir()
+ Path(".hidden/b.txt").write_text("b")
+ """
+ ).strip()
+
+ result = self.eval_file(code)
+ self.assertEqual(result.returncode, 0)
+ self.assertEqual(len(result.files), 1)
+ self.assertEqual(result.files[0].content, b"a")
+
def test_forkbomb_resource_unavailable(self):
code = dedent(
"""