summaryrefslogtreecommitdiff
path: root/test/test_execfile.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_execfile.py')
-rw-r--r--test/test_execfile.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_execfile.py b/test/test_execfile.py
new file mode 100644
index 00000000..90340f57
--- /dev/null
+++ b/test/test_execfile.py
@@ -0,0 +1,19 @@
+from coverage.execfile import run_python_file
+import cStringIO, os, sys, unittest
+
+here = os.path.dirname(__file__)
+
+class RunTests(unittest.TestCase):
+ def setUp(self):
+ self.oldstdout = sys.stdout
+ self.stdout = sys.stdout = cStringIO.StringIO()
+
+ def tearDown(self):
+ self.stdout = self.oldstdout
+
+ def test_run_python_file(self):
+ tryfile = os.path.join(here, "try_execfile.py")
+ run_python_file(tryfile)
+ mod_globs = eval(self.stdout.getvalue())
+ self.assertEqual(mod_globs['__name__'], "__main__")
+ self.assertEqual(os.path.basename(mod_globs['__file__']), "try_execfile.py")