From b3310c1889fc5f53275f6e9b2baa2a8b5d1a1d91 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Tue, 14 Apr 2015 18:19:20 -0400 Subject: Look for __main__ module if coverage is being run for directory #252 --- tests/test_execfile.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/test_execfile.py') diff --git a/tests/test_execfile.py b/tests/test_execfile.py index 49d6cc8c..9c2bc7d6 100644 --- a/tests/test_execfile.py +++ b/tests/test_execfile.py @@ -82,6 +82,15 @@ class RunFileTest(CoverageTest): with self.assertRaises(NoSource): 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") + + 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]) class RunPycFileTest(CoverageTest): """Test cases for `run_python_file`.""" -- cgit v1.2.1