diff options
| author | Tarek Ziade <tarek@ziade.org> | 2011-01-29 12:59:03 +0100 |
|---|---|---|
| committer | Tarek Ziade <tarek@ziade.org> | 2011-01-29 12:59:03 +0100 |
| commit | 4aa91e6aeb12e093c297f5cc439407ffa59ea156 (patch) | |
| tree | 7d426becd92b78d9f6a97222117e1f8e57d308d4 /distutils2/tests | |
| parent | deb4f4480f20f5c9f1321ec35599ee401bc96b2f (diff) | |
| download | disutils2-4aa91e6aeb12e093c297f5cc439407ffa59ea156.tar.gz | |
simplified the package_dir option - just one root dir allowed
Diffstat (limited to 'distutils2/tests')
| -rw-r--r-- | distutils2/tests/test_command_build_ext.py | 6 | ||||
| -rw-r--r-- | distutils2/tests/test_command_build_py.py | 24 | ||||
| -rw-r--r-- | distutils2/tests/test_config.py | 23 |
3 files changed, 33 insertions, 20 deletions
diff --git a/distutils2/tests/test_command_build_ext.py b/distutils2/tests/test_command_build_ext.py index 8b707d1..2434e33 100644 --- a/distutils2/tests/test_command_build_ext.py +++ b/distutils2/tests/test_command_build_ext.py @@ -289,7 +289,7 @@ class BuildExtTestCase(support.TempdirManager, # inplace = 0, cmd.package = 'bar' build_py = cmd.get_finalized_command('build_py') - build_py.package_dir = {'': 'bar'} + build_py.package_dir = 'bar' path = cmd.get_ext_fullpath('foo') # checking that the last directory is the build_dir path = os.path.split(path)[0] @@ -318,7 +318,7 @@ class BuildExtTestCase(support.TempdirManager, dist = Distribution() cmd = build_ext(dist) cmd.inplace = 1 - cmd.distribution.package_dir = {'': 'src'} + cmd.distribution.package_dir = 'src' cmd.distribution.packages = ['lxml', 'lxml.html'] curdir = os.getcwd() wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext) @@ -334,7 +334,7 @@ class BuildExtTestCase(support.TempdirManager, # building twisted.runner.portmap not inplace build_py = cmd.get_finalized_command('build_py') - build_py.package_dir = {} + build_py.package_dir = None cmd.distribution.packages = ['twisted', 'twisted.runner.portmap'] path = cmd.get_ext_fullpath('twisted.runner.portmap') wanted = os.path.join(curdir, 'tmpdir', 'twisted', 'runner', diff --git a/distutils2/tests/test_command_build_py.py b/distutils2/tests/test_command_build_py.py index eefdc69..38ff7a6 100644 --- a/distutils2/tests/test_command_build_py.py +++ b/distutils2/tests/test_command_build_py.py @@ -17,12 +17,14 @@ class BuildPyTestCase(support.TempdirManager, def test_package_data(self): sources = self.mkdtemp() - f = open(os.path.join(sources, "__init__.py"), "w") + pkg_dir = os.path.join(sources, 'pkg') + os.mkdir(pkg_dir) + f = open(os.path.join(pkg_dir, "__init__.py"), "w") try: f.write("# Pretend this is a package.") finally: f.close() - f = open(os.path.join(sources, "README.txt"), "w") + f = open(os.path.join(pkg_dir, "README.txt"), "w") try: f.write("Info about this package") finally: @@ -31,8 +33,9 @@ class BuildPyTestCase(support.TempdirManager, destination = self.mkdtemp() dist = Distribution({"packages": ["pkg"], - "package_dir": {"pkg": sources}}) + "package_dir": sources}) # script_name need not exist, it just need to be initialized + dist.script_name = os.path.join(sources, "setup.py") dist.command_obj["build"] = support.DummyCommand( force=0, @@ -42,7 +45,7 @@ class BuildPyTestCase(support.TempdirManager, use_2to3=False) dist.packages = ["pkg"] dist.package_data = {"pkg": ["README.txt"]} - dist.package_dir = {"pkg": sources} + dist.package_dir = sources cmd = build_py(dist) cmd.compile = 1 @@ -68,19 +71,20 @@ class BuildPyTestCase(support.TempdirManager, # create the distribution files. sources = self.mkdtemp() - open(os.path.join(sources, "__init__.py"), "w").close() - - testdir = os.path.join(sources, "doc") + pkg = os.path.join(sources, 'pkg') + os.mkdir(pkg) + open(os.path.join(pkg, "__init__.py"), "w").close() + testdir = os.path.join(pkg, "doc") os.mkdir(testdir) open(os.path.join(testdir, "testfile"), "w").close() os.chdir(sources) old_stdout = sys.stdout - sys.stdout = StringIO.StringIO() + #sys.stdout = StringIO.StringIO() try: dist = Distribution({"packages": ["pkg"], - "package_dir": {"pkg": ""}, + "package_dir": sources, "package_data": {"pkg": ["doc/*"]}}) # script_name need not exist, it just need to be initialized dist.script_name = os.path.join(sources, "setup.py") @@ -89,7 +93,7 @@ class BuildPyTestCase(support.TempdirManager, try: dist.run_commands() - except DistutilsFileError: + except DistutilsFileError, e: self.fail("failed package_data test when package_dir is ''") finally: # Restore state. diff --git a/distutils2/tests/test_config.py b/distutils2/tests/test_config.py index bdd4739..5fdb04c 100644 --- a/distutils2/tests/test_config.py +++ b/distutils2/tests/test_config.py @@ -49,9 +49,11 @@ project_url = Fork in progress, http://bitbucket.org/Merwok/sample-distutils2-project [files] +packages_root = src + packages = one - src:two - src2:three + two + three modules = haven @@ -140,6 +142,7 @@ class ConfigTestCase(support.TempdirManager, opts.update(kwargs) self.write_file('setup.cfg', SETUP_CFG % opts) + def run_setup(self, *args): # run setup with args sys.stdout = StringIO() @@ -198,7 +201,6 @@ class ConfigTestCase(support.TempdirManager, 'http://bitbucket.org/Merwok/sample-distutils2-project')] self.assertEqual(dist.metadata['Project-Url'], urls) - self.assertEqual(dist.packages, ['one', 'two', 'three']) self.assertEqual(dist.py_modules, ['haven']) self.assertEqual(dist.package_data, {'cheese': 'data/templates/*'}) @@ -206,7 +208,8 @@ class ConfigTestCase(support.TempdirManager, [('bitmaps ', ['bm/b1.gif', 'bm/b2.gif']), ('config ', ['cfg/data.cfg']), ('/etc/init.d ', ['init-script'])]) - self.assertEqual(dist.package_dir['two'], 'src') + + self.assertEqual(dist.package_dir, 'src') # Make sure we get the foo command loaded. We use a string comparison # instead of assertIsInstance because the class is not the same when @@ -262,7 +265,9 @@ class ConfigTestCase(support.TempdirManager, os.mkdir('bin') self.write_file(os.path.join('bin', 'taunt'), '#') - for pkg in ('one', 'src', 'src2'): + os.mkdir('src') + for pkg in ('one', 'two', 'three'): + pkg = os.path.join('src', pkg) os.mkdir(pkg) self.write_file(os.path.join(pkg, '__init__.py'), '#') @@ -285,7 +290,9 @@ class ConfigTestCase(support.TempdirManager, os.mkdir('bin') self.write_file(os.path.join('bin', 'taunt'), '#') - for pkg in ('one', 'src', 'src2'): + os.mkdir('src') + for pkg in ('one', 'two', 'three'): + pkg = os.path.join('src', pkg) os.mkdir(pkg) self.write_file(os.path.join(pkg, '__init__.py'), '#') @@ -310,8 +317,10 @@ class ConfigTestCase(support.TempdirManager, self.write_file(os.path.join('scripts', 'find-coconuts'), '#') os.mkdir('bin') self.write_file(os.path.join('bin', 'taunt'), '#') + os.mkdir('src') - for pkg in ('one', 'src', 'src2'): + for pkg in ('one', 'two', 'three'): + pkg = os.path.join('src', pkg) os.mkdir(pkg) self.write_file(os.path.join(pkg, '__init__.py'), '#') |
