comparison tests/test_ttw.txt @ 69:10f343c483ee

install and import the thing
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 02 Mar 2012 10:13:25 -0800
parents e62d2fddb275
children
comparison
equal deleted inserted replaced
68:e62d2fddb275 69:10f343c483ee
30 >>> 'Python Package Index' in contents 30 >>> 'Python Package Index' in contents
31 True 31 True
32 32
33 Get the index page:: 33 Get the index page::
34 34
35 >>> resource = urllib2.urlopen(url + 'index') 35 >>> index = url + 'index/'
36 >>> resource = urllib2.urlopen(index)
36 >>> contents = resource.read() 37 >>> contents = resource.read()
37 >>> 'Simple Index' in contents 38 >>> 'Simple Index' in contents
38 True 39 True
39 40
40 41
62 >>> tmpdir = tempfile.mkdtemp() 63 >>> tmpdir = tempfile.mkdtemp()
63 >>> venv = create_virtualenv(tmpdir) 64 >>> venv = create_virtualenv(tmpdir)
64 >>> code = subprocess.call([venv.python, '-c', 'import helloworld'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) 65 >>> code = subprocess.call([venv.python, '-c', 'import helloworld'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
65 >>> code 66 >>> code
66 1 67 1
68
69 Install the package and make sure you can import it::
70
71 >>> subprocess.call([venv.easy_install, '-i', index, 'HelloWorld'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
72 0
73 >>> code = subprocess.call([venv.python, '-c', 'import helloworld'])
74 >>> code
75 0
76 >>> process = subprocess.Popen([venv.python, '-c', 'import helloworld; print helloworld.hello'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
77 >>> stdout, stderr = process.communicate()
78 >>> stdout
79 'Hello, world!\n'
80 >>> process.returncode
81 0
67 >>> shutil.rmtree(tmpdir) 82 >>> shutil.rmtree(tmpdir)
68 83
69 Shut down the server:: 84 Shut down the server::
70 85
71 >>> server.stop() 86 >>> server.stop()