Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: recipe_engine/third_party/setuptools/tests/test_upload_docs.py

Issue 1344583003: Recipe package system. (Closed) Base URL: git@github.com:luci/recipes-py.git@master
Patch Set: Recompiled proto Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 """build_ext tests
2 """
3 import sys, os, shutil, tempfile, unittest, site, zipfile
4 from setuptools.command.upload_docs import upload_docs
5 from setuptools.dist import Distribution
6
7 SETUP_PY = """\
8 from setuptools import setup
9
10 setup(name='foo')
11 """
12
13 class TestUploadDocsTest(unittest.TestCase):
14 def setUp(self):
15 self.dir = tempfile.mkdtemp()
16 setup = os.path.join(self.dir, 'setup.py')
17 f = open(setup, 'w')
18 f.write(SETUP_PY)
19 f.close()
20 self.old_cwd = os.getcwd()
21 os.chdir(self.dir)
22
23 self.upload_dir = os.path.join(self.dir, 'build')
24 os.mkdir(self.upload_dir)
25
26 # A test document.
27 f = open(os.path.join(self.upload_dir, 'index.html'), 'w')
28 f.write("Hello world.")
29 f.close()
30
31 # An empty folder.
32 os.mkdir(os.path.join(self.upload_dir, 'empty'))
33
34 if sys.version >= "2.6":
35 self.old_base = site.USER_BASE
36 site.USER_BASE = upload_docs.USER_BASE = tempfile.mkdtemp()
37 self.old_site = site.USER_SITE
38 site.USER_SITE = upload_docs.USER_SITE = tempfile.mkdtemp()
39
40 def tearDown(self):
41 os.chdir(self.old_cwd)
42 shutil.rmtree(self.dir)
43 if sys.version >= "2.6":
44 shutil.rmtree(site.USER_BASE)
45 shutil.rmtree(site.USER_SITE)
46 site.USER_BASE = self.old_base
47 site.USER_SITE = self.old_site
48
49 def test_create_zipfile(self):
50 # Test to make sure zipfile creation handles common cases.
51 # This explicitly includes a folder containing an empty folder.
52
53 dist = Distribution()
54
55 cmd = upload_docs(dist)
56 cmd.upload_dir = self.upload_dir
57 cmd.target_dir = self.upload_dir
58 tmp_dir = tempfile.mkdtemp()
59 tmp_file = os.path.join(tmp_dir, 'foo.zip')
60 try:
61 zip_file = cmd.create_zipfile(tmp_file)
62
63 assert zipfile.is_zipfile(tmp_file)
64
65 zip_file = zipfile.ZipFile(tmp_file) # woh...
66
67 assert zip_file.namelist() == ['index.html']
68
69 zip_file.close()
70 finally:
71 shutil.rmtree(tmp_dir)
72
OLDNEW
« no previous file with comments | « recipe_engine/third_party/setuptools/tests/test_test.py ('k') | recipe_engine/third_party/setuptools/unicode_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698