def test_cd(self): pwd = sh.pwd() sh.cd('..') self.assertNotEqual(pwd, sh.env.pwd) self.assertEqual(sh.pwd(), sh.env.pwd) sh.cd(pwd) # test with with with sh.cd('..') as newd: self.assertNotEqual(pwd, sh.env.pwd) self.assertEqual(sh.pwd(), sh.env.pwd) self.assertEqual(newd, sh.env.pwd) self.assertEqual(sh.pwd(), pwd)
def test_cd(self): pwd = sh.pwd() sh.cd('..') self.assertNotEqual(pwd, sh.env.pwd) self.assertEqual(sh.pwd(), sh.env.pwd) sh.cd(pwd)
def post_render(config): target_directory = os.path.abspath(config.target_directory) pkg = config.variables['package.directory'] pkg_dir = os.path.join(target_directory, pkg) if not test.d(pkg_dir): mkdir(pkg_dir) with open(os.path.join(pkg_dir, '__init__.py'), 'wb') as fd: fd.write('# package\n') doc_root = os.path.join(target_directory, 'docs') vars = config.variables d = dict(path=doc_root, author=vars['author.name'], project=vars['package.name'], version='', ext_autodoc='y', ext_viewcode='y', batchfile=False) quickstart_do_prompt = quickstart.do_prompt def do_prompt(d, key, text, default=None, validator=quickstart.nonempty): print(key) if key in use_defaults: if default == 'y': default = True elif default == 'n': default = False d[key] = default elif key not in d: quickstart_do_prompt(d, key, text, default, validator) quickstart.do_prompt = do_prompt if not os.path.isdir(doc_root): # launch sphinx quickstart.ask_user(d) quickstart.generate(d) filename = os.path.join(doc_root, 'conf.py') # patch some files with open(filename, 'ab') as fd: fd.write(''' html_theme = 'nature' import pkg_resources version = pkg_resources.get_distribution("%s").version release = version ''' % vars['package.name']) filename = os.path.join(doc_root, 'Makefile') with open(filename, 'rb') as fd: data = fd.read() data = data.replace('sphinx-build', '../bin/sphinx-build') with open(filename, 'wb') as fd: fd.write(data) # launch buildout cd(target_directory) if not test.f('bootstrap.py'): wget('-O bootstrap.py', 'https://bootstrap.pypa.io/bootstrap-buildout.py') > 1 chmod('+x bootstrap.py') sh.python('bootstrap.py --allow-site-packages') > 1 if test.f('bin/buildout'): sh.python('bin/buildout') > 1