本文整理汇总了Python中sourcetree.SourceTree类的典型用法代码示例。如果您正苦于以下问题:Python SourceTree类的具体用法?Python SourceTree怎么用?Python SourceTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SourceTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_running_interactive_command
def test_running_interactive_command(self):
sourcetree = SourceTree()
command = "python3 -c \"print('input please?'); a = input();print('OK' if a=='yes' else 'NO')\""
output = sourcetree.run_command(command, user_input='no')
assert 'NO' in output
output = sourcetree.run_command(command, user_input='yes')
assert 'OK' in output
示例2: test_running_interactive_command
def test_running_interactive_command(self):
sourcetree = SourceTree()
sourcetree.run_command("mkdir superlists", cwd=sourcetree.tempdir)
command = "python3 -c \"print('input please?'); a = input();print('OK' if a=='yes' else 'NO')\""
output = sourcetree.run_command(command, user_input="no")
assert "NO" in output
output = sourcetree.run_command(command, user_input="yes")
assert "OK" in output
示例3: test_special_cases_fab_deploy
def test_special_cases_fab_deploy(self, mock_subprocess):
mock_subprocess.Popen.return_value.returncode = 0
mock_subprocess.Popen.return_value.communicate.return_value = 'a', 'b'
sourcetree = SourceTree()
sourcetree.run_command('fab deploy:[email protected]')
expected = (
'cd deploy_tools &&'
' fab -D -i'
' ~/Dropbox/Book/.vagrant/machines/default/virtualbox/private_key'
' deploy:[email protected]'
)
assert mock_subprocess.Popen.call_args[0][0] == expected
示例4: setUp
def setUp(self):
self.sourcetree = SourceTree()
self.tempdir = self.sourcetree.tempdir
self.processes = []
self.pos = 0
self.dev_server_running = False
self.current_server_cd = None
示例5: setUp
def setUp(self):
self.sourcetree = SourceTree()
self.sourcetree.get_local_repo_path = lambda c: os.path.abspath(os.path.join(
os.path.dirname(__file__), 'testrepo'
))
self.sourcetree.start_with_checkout(17)
self.sourcetree.run_command('git checkout test-start')
self.sourcetree.run_command('git reset')
示例6: test_checks_out_repo_current_chapter_as_master
def test_checks_out_repo_current_chapter_as_master(self):
sourcetree = SourceTree()
sourcetree.get_local_repo_path = lambda c: os.path.abspath(os.path.join(os.path.dirname(__file__), "testrepo"))
sourcetree.start_with_checkout(21)
remotes = sourcetree.run_command("git remote").split()
assert remotes == ["repo"]
branch = sourcetree.run_command("git branch").strip()
assert branch == "* master"
diff = sourcetree.run_command("git diff repo/chapter_20").strip()
assert diff == ""
示例7: test_checks_out_repo_chapter_as_master
def test_checks_out_repo_chapter_as_master(self):
sourcetree = SourceTree()
sourcetree.get_local_repo_path = lambda c: os.path.abspath(os.path.join(
os.path.dirname(__file__), 'testrepo'
))
sourcetree.start_with_checkout('chapter_17', 'chapter_16')
remotes = sourcetree.run_command('git remote').split()
assert remotes == ['repo']
branch = sourcetree.run_command('git branch').strip()
assert branch == '* master'
diff = sourcetree.run_command('git diff repo/chapter_16').strip()
assert diff == ''
示例8: test_cleanup_kills_backgrounded_processes_and_rmdirs
def test_cleanup_kills_backgrounded_processes_and_rmdirs(self):
sourcetree = SourceTree()
sourcetree.run_command('python -c"import time; time.sleep(5)" & #runserver', cwd=sourcetree.tempdir)
assert len(sourcetree.processes) == 1
sourcetree_pid = sourcetree.processes[0].pid
pids = subprocess.check_output('pgrep -f time.sleep', shell=True).decode('utf8').split()
print('sourcetree_pid', sourcetree_pid)
print('pids', pids)
sids = []
for pid in reversed(pids):
print('checking', pid)
cmd = 'ps -o sid --no-header -p %s' % (pid,)
print(cmd)
try:
sid = subprocess.check_output(cmd, shell=True)
print('sid', sid)
sids.append(sid)
assert sourcetree_pid == int(sid)
except subprocess.CalledProcessError:
pass
assert sids
sourcetree.cleanup()
assert 'time.sleep' not in subprocess.check_output('ps auxf', shell=True).decode('utf8')
示例9: test_special_cases_wget_bootstrap
def test_special_cases_wget_bootstrap(self):
sourcetree = SourceTree()
sourcetree.run_command("mkdir superlists", cwd=sourcetree.tempdir)
with patch("sourcetree.subprocess") as mock_subprocess:
mock_subprocess.Popen.return_value.communicate.return_value = ("bla bla", None)
sourcetree.run_command(BOOTSTRAP_WGET)
assert not mock_subprocess.Popen.called
assert os.path.exists(os.path.join(sourcetree.tempdir, "superlists", "bootstrap.zip"))
diff = sourcetree.run_command(
"diff %s bootstrap.zip" % (os.path.join(os.path.dirname(__file__), "..", "downloads", "bootstrap-3.0.zip"))
)
assert diff == ""
示例10: test_special_cases_wget_bootstrap
def test_special_cases_wget_bootstrap(self):
sourcetree = SourceTree()
sourcetree.run_command('mkdir superlists', cwd=sourcetree.tempdir)
with patch('sourcetree.subprocess') as mock_subprocess:
mock_subprocess.Popen.return_value.communicate.return_value = (
'bla bla', None
)
sourcetree.run_command(BOOTSTRAP_WGET)
assert not mock_subprocess.Popen.called
assert os.path.exists(os.path.join(sourcetree.tempdir, 'superlists', 'bootstrap.zip'))
diff = sourcetree.run_command('diff %s bootstrap.zip' % (
os.path.join(os.path.dirname(__file__), '..', 'downloads', 'bootstrap.zip'))
)
assert diff == ''
示例11: test_doesnt_raise_for_some_things_where_a_return_code_is_ok
def test_doesnt_raise_for_some_things_where_a_return_code_is_ok(self):
sourcetree = SourceTree()
sourcetree.run_command('diff foo bar', cwd=sourcetree.tempdir)
sourcetree.run_command('python test.py', cwd=sourcetree.tempdir)
示例12: test_environment_variables
def test_environment_variables(self):
sourcetree = SourceTree()
os.environ['TEHFOO'] = 'baz'
output = sourcetree.run_command('echo $TEHFOO', cwd=sourcetree.tempdir)
assert output.strip() == 'baz'
示例13: test_raises_on_errors
def test_raises_on_errors(self):
sourcetree = SourceTree()
with self.assertRaises(Exception):
sourcetree.run_command('synt!tax error', cwd=sourcetree.tempdir)
sourcetree.run_command('synt!tax error', cwd=sourcetree.tempdir, ignore_errors=True)
示例14: test_returns_output
def test_returns_output(self):
sourcetree = SourceTree()
output = sourcetree.run_command('echo hello', cwd=sourcetree.tempdir)
assert output == 'hello\n'
示例15: test_running_simple_command
def test_running_simple_command(self):
sourcetree = SourceTree()
sourcetree.run_command('touch foo', cwd=sourcetree.tempdir)
assert os.path.exists(os.path.join(sourcetree.tempdir, 'foo'))