def configure_role(): print('\n\nROLE CONFIGURATION:\n===================') for folder_name, folder in folders.items(): if query_yes_no(folder['question']): try: # this file has to be there, git doesn't store empty folders. os.remove(os.path.join(folder_name, '.empty')) except OSError: pass if 'hint' in folder: with open('{}/main.yml'.format(folder_name), 'a') as fp: if 'pre_hint' in folder: if query_yes_no(folder['pre_hint']): fp.write(folder['pre_action']) else: continue action_name = input(folder['hint']) while action_name: fp.write(folder['action'].format(action_name)) action_name = input(folder['hint']) else: shutil.rmtree(folder_name)
def test_query_bad_default(self, monkeypatch): monkeypatch.setattr( 'cookiecutter.prompt.read_response', lambda x=u'': u'junk' ) with pytest.raises(ValueError): prompt.query_yes_no('Blah?', default='yn')
def test_query_n(self): if not PY3: sys.stdin = StringIO('no') answer = prompt.query_yes_no("Blah?") self.assertFalse(answer)
def test_query_yes(self): if not PY3: sys.stdin = StringIO('yes') answer = prompt.query_yes_no("Blah?") self.assertTrue(answer)
def test_query_n(self): answer = prompt.query_yes_no("Blah?") self.assertFalse(answer)
def test_query_yes(self): answer = prompt.query_yes_no("Blah?") self.assertTrue(answer)
def test_query(self): assert prompt.query_yes_no('Blah?')
def test_query_no_default(self): if not PY3: sys.stdin = StringIO('\n') answer = prompt.query_yes_no("Blah?", default='no') self.assertFalse(answer)
def test_query_y_none_default(self): if not PY3: sys.stdin = StringIO('y') answer = prompt.query_yes_no("Blah?", default=None) self.assertTrue(answer)
def test_query_no_default(self): answer = prompt.query_yes_no("Blah?", default='no') self.assertFalse(answer)
def test_query_y_none_default(self): answer = prompt.query_yes_no("Blah?", default=None) self.assertTrue(answer)
def test_query_y(self): if not PY3: sys.stdin = StringIO('y') answer = prompt.query_yes_no("Blah?") self.assertTrue(answer)
def test_query_no_default(self, monkeypatch): monkeypatch.setattr( 'cookiecutter.prompt.read_response', lambda x=u'': u'' ) assert not prompt.query_yes_no('Blah?', default='no')
def test_query_n_none_default(self, monkeypatch): monkeypatch.setattr( 'cookiecutter.prompt.read_response', lambda x=u'': u'n' ) assert not prompt.query_yes_no("Blah?", default=None)