Exemplo n.º 1
0
 def _configure_babel(cls, course):
     with common_utils.ZipAwareOpen():
         # Internally, babel uses the 'en' locale, and we must configure it
         # before we make babel calls.
         localedata.load('en')
         # Also load the course's default language.
         localedata.load(course.default_locale)
Exemplo n.º 2
0
    def test_find_in_lib_with_relative_path(self):
        path = os.path.join(appengine_config.BUNDLE_ROOT, 'lib',
                            'markdown-2.5.zip', 'setup.cfg')

        with self.assertRaises(IOError):
            open(path)  # This fails.
        with utils.ZipAwareOpen():
            data = open(path).read()
            self.assertEquals(12, len(data))
Exemplo n.º 3
0
    def test_find_in_lib_without_relative_path(self):
        path = os.path.join(appengine_config.BUNDLE_ROOT, 'lib',
                            'babel-0.9.6.zip', 'babel', 'localedata',
                            'root.dat')
        with self.assertRaises(IOError):
            open(path)  # This fails.
        with utils.ZipAwareOpen():
            data = open(path).read()
            self.assertEquals(17490, len(data))

            data = open(path, 'r').read()
            self.assertEquals(17490, len(data))

            data = open(path, mode='r').read()
            self.assertEquals(17490, len(data))

            data = open(name=path, mode='r').read()
            self.assertEquals(17490, len(data))

            data = open(name=path).read()
            self.assertEquals(17490, len(data))

        with self.assertRaises(IOError):
            open(path)  # This fails again; open has been reset to normal.