summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2008-04-04 05:41:30 (GMT)
committerFred Drake <fdrake@acm.org>2008-04-04 05:41:30 (GMT)
commit46c58c17f18b87f4a3d3d363f171cff1715981d1 (patch)
tree0345b6b8417d022f34863667803b07ca305250bd /Lib/distutils/tests
parent2b860db35c5346c216672f94031ecc800dbebf02 (diff)
downloadcpython-46c58c17f18b87f4a3d3d363f171cff1715981d1.zip
cpython-46c58c17f18b87f4a3d3d363f171cff1715981d1.tar.gz
cpython-46c58c17f18b87f4a3d3d363f171cff1715981d1.tar.bz2
- Issue #2385: distutils.core.run_script() makes __file__ available, so the
controlled environment will more closely mirror the typical script environment. This supports setup.py scripts that refer to data files.
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r--Lib/distutils/tests/test_core.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/Lib/distutils/tests/test_core.py b/Lib/distutils/tests/test_core.py
new file mode 100644
index 0000000..6de58d9
--- /dev/null
+++ b/Lib/distutils/tests/test_core.py
@@ -0,0 +1,40 @@
+"""Tests for distutils.core."""
+
+import StringIO
+import distutils.core
+import os
+import test.test_support
+import unittest
+
+
+# setup script that uses __file__
+setup_using___file__ = """\
+
+__file__
+
+from distutils.core import setup
+setup()
+"""
+
+
+class CoreTestCase(unittest.TestCase):
+
+ def tearDown(self):
+ os.remove(test.test_support.TESTFN)
+
+ def write_setup(self, text):
+ return fn
+
+ def test_run_setup_provides_file(self):
+ # Make sure the script can use __file__; if that's missing, the test
+ # setup.py script will raise NameError.
+ fn = test.test_support.TESTFN
+ open(fn, "w").write(setup_using___file__)
+ distutils.core.run_setup(fn)
+
+
+def test_suite():
+ return unittest.makeSuite(CoreTestCase)
+
+if __name__ == "__main__":
+ unittest.main(defaultTest="test_suite")