summaryrefslogtreecommitdiff
path: root/tests/test_process.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_process.py')
-rw-r--r--tests/test_process.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_process.py b/tests/test_process.py
index 0979cc2c..a5303338 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -1293,6 +1293,36 @@ class UnicodeFilePathsTest(CoverageTest):
self.assertEqual(out, report_expected)
+class YankedDirectoryTest(CoverageTest):
+ """Tests of what happens when the current directory is deleted."""
+
+ BUG_806 = """\
+ import os
+ import sys
+ import tempfile
+
+ tmpdir = tempfile.mkdtemp()
+ os.chdir(tmpdir)
+ os.rmdir(tmpdir)
+ print(sys.argv[1])
+ """
+
+ def test_removing_directory(self):
+ self.make_file("bug806.py", self.BUG_806)
+ out = self.run_command("coverage run bug806.py noerror")
+ self.assertEqual(out, "noerror\n")
+
+ def test_removing_directory_with_error(self):
+ self.make_file("bug806.py", self.BUG_806)
+ out = self.run_command("coverage run bug806.py")
+ self.assertEqual(out, textwrap.dedent("""\
+ Traceback (most recent call last):
+ File "bug806.py", line 8, in <module>
+ print(sys.argv[1])
+ IndexError: list index out of range
+ """))
+
+
def possible_pth_dirs():
"""Produce a sequence of directories for trying to write .pth files."""
# First look through sys.path, and if we find a .pth file, then it's a good