Beispiel #1
0
    def test_get_revision(self):
        py.test.skip('XXX changed implementation (temporarily?)')
        if py.std.sys.platform.startswith('win'):
            py.test.skip('broken on win32 for some reason (svn caching?), '
                         'skipping')
        repo = make_test_repo('test_get_revision_source_repo')
        wc = py.path.svnwc(py.test.ensuretemp('test_get_revision_source_wc'))
        wc.checkout(repo.url)

        dir = wc.ensure('dir', dir=True)
        file = dir.ensure('file.py', file=True)
        wc.commit('added dir and file')
        wc.update()
        assert file.check(versioned=True)
        assert wc.status().rev == '1'

        assert self.spb.get_revision(dir) == 1
        assert self.spb.get_revision(file) == 1

        file.write('while 1:\n  print "py lib is cool\n"')
        file.commit('added some code')
        assert file.status().rev == '2'
        self.spb._revcache = {}
        assert self.spb.get_revision(file) == 2
        assert self.spb.get_revision(dir) == 1
Beispiel #2
0
 def setup_class(cls):
     cls.repo = make_test_repo()
     cls.wc = py.path.svnwc(py.test.ensuretemp("test-wc").join("wc"))
Beispiel #3
0
 def setup_class(cls):
     getsvnbin()
     cls.repo = make_test_repo()
     cls.wc = py.path.svnwc(py.test.ensuretemp("test-wc").join("wc"))
Beispiel #4
0
    def test_get_revision(self):
        py.test.skip('XXX changed implementation (temporarily?)')
        if py.std.sys.platform.startswith('win'):
            py.test.skip('broken on win32 for some reason (svn caching?), '
                         'skipping')
        # XXX a lot of setup required for this one... more like a functional
        # test I fear
        
        # create test repo and checkout
        repo = make_test_repo('test_get_revision_api_repo')
        wc = py.path.svnwc(py.test.ensuretemp('test_get_revision_api_wc'))
        wc.checkout(repo.url)
        assert wc.status().rev == '0'

        # create a temp package inside the working copy
        fs_root, pkg_name = setup_fs_project(wc)
        ds, dsa = get_dsa(self.fs_root, self.pkg_name)
        wc.commit('test get revision commit')
        wc.update()

        # clear cache
        py.__.apigen.htmlgen._get_obj_cache = {}

        # fiddle about a bit with paths so that our package is picked up :|
        old_path = py.std.sys.path
        try:
            py.std.sys.path.insert(0, fs_root.strpath)
            pkgkeys = [k for k in py.std.sys.modules.keys() if
                       k == 'pkg' or k.startswith('pkg.')]
            # remove modules from sys.modules
            for key in pkgkeys:
                del py.std.sys.modules[key]

            # now create a new apb that uses the wc pkg
            apb = ApiPageBuilder(self.base, self.linker, dsa,
                                 fs_root.join(pkg_name),
                                 self.namespace_tree, self.project)
            apb._revcache = {} # clear cache, this is on class level!!

            pkg = wc.join('pkg')
            assert pkg.check(versioned=True)
            assert pkg.info().created_rev == 1

            funcpath = pkg.join('func.py')
            classpath = pkg.join('someclass.py')
            assert funcpath.check(versioned=True)
            assert classpath.check(versioned=True)
            assert apb.get_revision('main.sub.func') == 1
            assert apb.get_revision('main.SomeClass') == 1
            assert apb.get_revision('') == 1
            assert apb.get_revision('main.sub') == 1
            funcpath.write(funcpath.read() + '\n')
            funcpath.commit('updated func')
            wc.update()
            apb._revcache = {} # clear cache
            assert apb.get_revision('main.sub.func') == 2
            assert apb.get_revision('') == 1
            assert apb.get_revision('main.SomeClass') == 1
        finally:
            py.std.sys.path = old_path
            # clear caches again
            py.__.apigen.htmlgen._get_obj_cache = {}
            apb._revcache = {}