Exemple #1
0
    def test_diff(self):
        port, pid = self._start_svnserve()
        try:
            wc = py.path.svnwc(self.temppath, auth=self.auth)
            wc.checkout(
                'svn://localhost:%s/%s' % (port, self.repopath.basename,))
            wc.ensure('foo', file=True)
            wc.commit('added foo file')
            wc.update()
            rev = int(wc.status().rev)
            foo = wc.join('foo')
            foo.write('bar')
            diff = foo.diff()
            assert '\n+bar\n' in diff
            foo.commit('added some content')
            diff = foo.diff()
            assert not diff
            diff = foo.diff(rev=rev)
            assert '\n+bar\n' in diff

            auth = py.path.SvnAuth('unknown', 'unknown', interactive=False)
            foo.auth = auth
            py.test.raises(Exception, 'foo.diff(rev=rev)')
        finally:
            killproc(pid)
Exemple #2
0
def test_win_killsubprocess():
    tmp = py.test.ensuretemp("test_win_killsubprocess")
    t = tmp.join("t.py")
    t.write("import time ; time.sleep(100)")
    proc = py.std.subprocess.Popen([sys.executable, str(t)])
    assert proc.poll() is None # no return value yet
    killproc(proc.pid)
    ret = proc.wait()
    assert ret != 0
Exemple #3
0
 def test_checkout_function_arg(self):
     port, pid = self._start_svnserve()
     try:
         wc = py.path.svnwc(self.temppath, auth=self.auth)
         wc.checkout(
             'svn://localhost:%s/%s' % (port, self.repopath.basename))
         assert wc.join('.svn').check()
     finally:
         killproc(pid)
Exemple #4
0
 def test_checkout_failing_non_interactive(self):
     port, pid = self._start_svnserve()
     try:
         auth = py.path.SvnAuth('johnny', 'bar', cache_auth=False,
                                interactive=False)
         wc = py.path.svnwc(self.temppath, auth)
         py.test.raises(Exception,
             ("wc.checkout('svn://localhost:%s/%s' % "
              "(port, self.repopath.basename))"))
     finally:
         killproc(pid)
Exemple #5
0
 def test_checkout_constructor_arg(self):
     port, pid = self._start_svnserve()
     try:
         wc = py.path.svnwc(self.temppath, auth=self.auth)
         wc.checkout(
             'svn://localhost:%s/%s' % (port, self.repopath.basename))
         assert wc.join('.svn').check()
     finally:
         # XXX can we do this in a teardown_method too? not sure if that's
         # guaranteed to get called...
         killproc(pid)
Exemple #6
0
 def test_log(self):
     port, pid = self._start_svnserve()
     try:
         wc = py.path.svnwc(self.temppath, self.auth)
         wc.checkout(
             'svn://localhost:%s/%s' % (port, self.repopath.basename))
         foo = wc.ensure('foo.txt')
         wc.commit('added foo.txt')
         log = foo.log()
         assert len(log) == 1
         assert log[0].msg == 'added foo.txt'
     finally:
         killproc(pid)
Exemple #7
0
 def test_switch(self):
     port, pid = self._start_svnserve()
     try:
         wc = py.path.svnwc(self.temppath, auth=self.auth)
         svnurl = 'svn://localhost:%s/%s' % (port, self.repopath.basename)
         wc.checkout(svnurl)
         wc.ensure('foo', dir=True).ensure('foo.txt').write('foo')
         wc.commit('added foo dir with foo.txt file')
         wc.ensure('bar', dir=True)
         wc.commit('added bar dir')
         bar = wc.join('bar')
         bar.switch(svnurl + '/foo')
         assert bar.join('foo.txt')
     finally:
         killproc(pid)
Exemple #8
0
def test_win_killsubprocess():
    if sys.platform == 'win32' and not py.path.local.sysfind('taskkill'):
        py.test.skip("you\'re using an older version of windows, which "
                     "doesn\'t support 'taskkill' - py.misc.killproc is not "
                     "available")
    try:
        import subprocess
    except ImportError:
        py.test.skip("no subprocess module")
    tmp = py.test.ensuretemp("test_win_killsubprocess")
    t = tmp.join("t.py")
    t.write("import time ; time.sleep(100)")
    proc = py.std.subprocess.Popen([sys.executable, str(t)])
    assert proc.poll() is None # no return value yet
    killproc(proc.pid)
    ret = proc.wait()
    assert ret != 0
Exemple #9
0
    def test_listdir(self):
        port, pid = self._start_svnserve()
        try:
            u = py.path.svnurl(
                'svn://localhost:%s/%s' % (port, self.repopath.basename),
                auth=self.auth)
            u.ensure('foo')
            paths = u.listdir()
            assert len(paths) == 1
            assert paths[0].auth is self.auth

            auth = SvnAuth('foo', 'bar', interactive=False)
            u = py.path.svnurl(
                'svn://localhost:%s/%s' % (port, self.repopath.basename),
                auth=auth)
            py.test.raises(Exception, 'u.listdir()')
        finally:
            killproc(pid)
Exemple #10
0
    def test_copy(self):
        port, pid = self._start_svnserve()
        try:
            u = py.path.svnurl(
                'svn://localhost:%s/%s' % (port, self.repopath.basename),
                auth=self.auth)
            foo = u.ensure('foo')
            bar = u.join('bar')
            foo.copy(bar)
            assert bar.check()
            assert bar.auth is self.auth

            auth = SvnAuth('foo', 'bar', interactive=False)
            u = py.path.svnurl(
                'svn://localhost:%s/%s' % (port, self.repopath.basename),
                auth=auth)
            foo = u.join('foo')
            bar = u.join('bar')
            py.test.raises(Exception, 'foo.copy(bar)')
        finally:
            killproc(pid)
Exemple #11
0
    def test_update(self):
        port, pid = self._start_svnserve()
        try:
            wc1 = py.path.svnwc(self.temppath.ensure('wc1', dir=True),
                                auth=self.auth)
            wc2 = py.path.svnwc(self.temppath.ensure('wc2', dir=True),
                                auth=self.auth)
            wc1.checkout(
                'svn://localhost:%s/%s' % (port, self.repopath.basename))
            wc2.checkout(
                'svn://localhost:%s/%s' % (port, self.repopath.basename))
            wc1.ensure('foo', dir=True)
            wc1.commit('added foo dir')
            wc2.update()
            assert wc2.join('foo').check()

            auth = py.path.SvnAuth('unknown', 'unknown', interactive=False)
            wc2.auth = auth
            py.test.raises(Exception, 'wc2.update()')
        finally:
            killproc(pid)
Exemple #12
0
    def test_write_read(self):
        port, pid = self._start_svnserve()
        try:
            u = py.path.svnurl(
                'svn://localhost:%s/%s' % (port, self.repopath.basename),
                auth=self.auth)
            foo = u.ensure('foo')
            fp = foo.open()
            try:
                data = fp.read()
            finally:
                fp.close()
            assert data == ''

            auth = SvnAuth('foo', 'bar', interactive=False)
            u = py.path.svnurl(
                'svn://localhost:%s/%s' % (port, self.repopath.basename),
                auth=auth)
            foo = u.join('foo')
            py.test.raises(Exception, 'foo.open()')
        finally:
            killproc(pid)
Exemple #13
0
    def test_lock_unlock_status(self):
        port, pid = self._start_svnserve()
        try:
            wc = py.path.svnwc(self.temppath, auth=self.auth)
            wc.checkout(
                'svn://localhost:%s/%s' % (port, self.repopath.basename,))
            wc.ensure('foo', file=True)
            wc.commit('added foo file')
            foo = wc.join('foo')
            foo.lock()
            status = foo.status()
            assert status.locked
            foo.unlock()
            status = foo.status()
            assert not status.locked

            auth = py.path.SvnAuth('unknown', 'unknown', interactive=False)
            foo.auth = auth
            py.test.raises(Exception, 'foo.lock()')
            py.test.raises(Exception, 'foo.unlock()')
        finally:
            killproc(pid)