Commit 98075501 authored by R. David Murray's avatar R. David Murray

Issue 6292: for the moment at least, the test suite passes if run

with -OO.  Tests requiring docstrings are skipped.  Patch by
Brian Curtin, thanks to Matias Torchinsky for helping review and
improve the patch.
parent eea5ca2f
......@@ -16,7 +16,7 @@ class BuildPyTestCase(support.TempdirManager,
support.LoggingSilencer,
unittest.TestCase):
def test_package_data(self):
def _setup_package_data(self):
sources = self.mkdtemp()
f = open(os.path.join(sources, "__init__.py"), "w")
f.write("# Pretend this is a package.")
......@@ -52,10 +52,19 @@ class BuildPyTestCase(support.TempdirManager,
self.assertEqual(len(cmd.get_outputs()), 3)
pkgdest = os.path.join(destination, "pkg")
files = os.listdir(pkgdest)
return files
def test_package_data(self):
files = self._setup_package_data()
self.assertTrue("__init__.py" in files)
self.assertTrue("__init__.pyc" in files)
self.assertTrue("README.txt" in files)
@unittest.skipIf(sys.flags.optimize >= 2,
"pyc files are not written with -O2 and above")
def test_package_data_pyc(self):
files = self._setup_package_data()
self.assertTrue("__init__.pyc" in files)
def test_empty_package_dir (self):
# See SF 1668596/1720897.
cwd = os.getcwd()
......
"""Tests for distutils.extension."""
import unittest
import os
import sys
import unittest
import warnings
from test.test_support import check_warnings
......@@ -32,16 +33,22 @@ class ExtensionTestCase(unittest.TestCase):
self.assertEquals(names, wanted)
def test_extension_init(self):
# the first argument, which is the name, must be a string
@unittest.skipIf(sys.flags.optimize >= 2,
"Assertions are omitted with -O2 and above")
def test_extension_init_assertions(self):
# The first argument, which is the name, must be a string.
self.assertRaises(AssertionError, Extension, 1, [])
ext = Extension('name', [])
self.assertEquals(ext.name, 'name')
# the second argument, which is the list of files, must
# be a list of strings
self.assertRaises(AssertionError, Extension, 'name', 'file')
self.assertRaises(AssertionError, Extension, 'name', ['file', 1])
def test_extension_init(self):
ext = Extension('name', [])
self.assertEquals(ext.name, 'name')
ext = Extension('name', ['file1', 'file2'])
self.assertEquals(ext.sources, ['file1', 'file2'])
......
"""Tests for distutils.command.install_data."""
import sys
import os
import sys
import unittest
from distutils.command.install_lib import install_lib
......@@ -31,9 +31,7 @@ class InstallLibTestCase(support.TempdirManager,
cmd.finalize_options()
self.assertEquals(cmd.optimize, 2)
@unittest.skipUnless(not sys.dont_write_bytecode,
'byte-compile not supported')
def test_byte_compile(self):
def _setup_byte_compile(self):
pkg_dir, dist = self.create_dist()
cmd = install_lib(dist)
cmd.compile = cmd.optimize = 1
......@@ -41,8 +39,15 @@ class InstallLibTestCase(support.TempdirManager,
f = os.path.join(pkg_dir, 'foo.py')
self.write_file(f, '# python file')
cmd.byte_compile([f])
self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyc')))
self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyo')))
return pkg_dir
@unittest.skipIf(sys.dont_write_bytecode, 'byte-compile not enabled')
def test_byte_compile(self):
pkg_dir = self._setup_byte_compile()
if sys.flags.optimize < 1:
self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyc')))
else:
self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyo')))
def test_get_outputs(self):
pkg_dir, dist = self.create_dist()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment