diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-08-01 17:15:27 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-08-01 17:15:27 -0400 |
commit | 5e45baa100135e2ef327feb767e8e027a58d1637 (patch) | |
tree | 352e759ace46d27e92a66b35045313abe7121e15 /tests/test_execfile.py | |
parent | 3e6e85a71c1ad66cd8ed658a61bedbff38f47dd1 (diff) | |
download | python-coveragepy-git-5e45baa100135e2ef327feb767e8e027a58d1637.tar.gz |
Support directories on the 'coverage run' command line. #252
Diffstat (limited to 'tests/test_execfile.py')
-rw-r--r-- | tests/test_execfile.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/test_execfile.py b/tests/test_execfile.py index 2533f81d..a3ea1153 100644 --- a/tests/test_execfile.py +++ b/tests/test_execfile.py @@ -86,14 +86,17 @@ class RunFileTest(CoverageTest): run_python_file("xyzzy.py", []) def test_directory_with_main(self): - directory_with_main = os.path.join(HERE, "with_main") - run_python_file(directory_with_main, [directory_with_main]) - self.assertEqual(self.stdout(), "1\n") + self.make_file("with_main/__main__.py", """\ + print("I am __main__") + """) + run_python_file("with_main", ["with_main"]) + self.assertEqual(self.stdout(), "I am __main__\n") def test_directory_without_main(self): - with self.assertRaises(NoSource): - directory_with_main = os.path.join(HERE, "with_main", "without") - run_python_file(directory_with_main, [directory_with_main]) + self.make_file("without_main/__init__.py", "") + with self.assertRaisesRegex(NoSource, "Can't find '__main__' module in 'without_main'"): + run_python_file("without_main", ["without_main"]) + class RunPycFileTest(CoverageTest): """Test cases for `run_python_file`.""" |