當前位置: 首頁>>代碼示例>>Python>>正文


Python sourcetree.SourceTree類代碼示例

本文整理匯總了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
開發者ID:hjwp,項目名稱:Book-TDD-Web-Dev-Python,代碼行數:8,代碼來源:test_sourcetree.py

示例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
開發者ID:abunuwas,項目名稱:Book-TDD-Web-Dev-Python,代碼行數:9,代碼來源:test_sourcetree.py

示例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
開發者ID:hjwp,項目名稱:Book-TDD-Web-Dev-Python,代碼行數:12,代碼來源:test_sourcetree.py

示例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
開發者ID:Lamhot,項目名稱:book-tdd-python,代碼行數:7,代碼來源:book_tester.py

示例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')
開發者ID:Lamhot,項目名稱:book-tdd-python,代碼行數:8,代碼來源:test_sourcetree.py

示例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 == ""
開發者ID:abunuwas,項目名稱:Book-TDD-Web-Dev-Python,代碼行數:10,代碼來源:test_sourcetree.py

示例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 == ''
開發者ID:hjwp,項目名稱:Book-TDD-Web-Dev-Python,代碼行數:12,代碼來源:test_sourcetree.py

示例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')
開發者ID:Lamhot,項目名稱:book-tdd-python,代碼行數:24,代碼來源:test_sourcetree.py

示例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 == ""
開發者ID:abunuwas,項目名稱:Book-TDD-Web-Dev-Python,代碼行數:12,代碼來源:test_sourcetree.py

示例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 == ''
開發者ID:Lamhot,項目名稱:book-tdd-python,代碼行數:14,代碼來源:test_sourcetree.py

示例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)
開發者ID:Lamhot,項目名稱:book-tdd-python,代碼行數:4,代碼來源:test_sourcetree.py

示例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'
開發者ID:Lamhot,項目名稱:book-tdd-python,代碼行數:5,代碼來源:test_sourcetree.py

示例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)
開發者ID:Lamhot,項目名稱:book-tdd-python,代碼行數:5,代碼來源:test_sourcetree.py

示例14: test_returns_output

 def test_returns_output(self):
     sourcetree = SourceTree()
     output = sourcetree.run_command('echo hello', cwd=sourcetree.tempdir)
     assert output == 'hello\n'
開發者ID:Lamhot,項目名稱:book-tdd-python,代碼行數:4,代碼來源:test_sourcetree.py

示例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'))
開發者ID:Lamhot,項目名稱:book-tdd-python,代碼行數:4,代碼來源:test_sourcetree.py


注:本文中的sourcetree.SourceTree類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。