summaryrefslogtreecommitdiff
path: root/tests/test_process.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2019-07-06 17:17:07 -0400
committerNed Batchelder <ned@nedbatchelder.com>2019-07-06 17:21:57 -0400
commit9ae35a5f6a4fed487ef6c14edd6b4eb4f5c1b7f0 (patch)
treeb7ffb1ea7045f75bcb78070e728693b7b0fd8023 /tests/test_process.py
parente5a59865b038ac575c4f8ca9e79c5b4802018ff1 (diff)
downloadpython-coveragepy-git-9ae35a5f6a4fed487ef6c14edd6b4eb4f5c1b7f0.tar.gz
Add tests of bug #806, and ensure it's fixed even if the program ends with an exception
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