summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcduvall@chromium.org <cduvall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-11 17:38:57 +0000
committercduvall@chromium.org <cduvall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-11 17:38:57 +0000
commit1686480f454eb6855810b69c0f9484233ba15313 (patch)
tree56275db3edf462bef74007f3c28bc28df34b88d4
parentd23a00cc195e92c4799afedbc0da5877f37cfe6c (diff)
downloadchromium_src-1686480f454eb6855810b69c0f9484233ba15313.zip
chromium_src-1686480f454eb6855810b69c0f9484233ba15313.tar.gz
chromium_src-1686480f454eb6855810b69c0f9484233ba15313.tar.bz2
Extensions Docs Server: Fix tests so they work from any directory
Tests now can be run from any directory. Review URL: https://chromiumcodereview.appspot.com/10916217 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156043 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xchrome/common/extensions/docs/server2/api_data_source_test.py3
-rwxr-xr-xchrome/common/extensions/docs/server2/branch_utility_test.py9
-rwxr-xr-xchrome/common/extensions/docs/server2/example_zipper_test.py6
-rwxr-xr-xchrome/common/extensions/docs/server2/github_file_system_test.py7
-rwxr-xr-xchrome/common/extensions/docs/server2/handlebar_dict_generator_test.py3
-rwxr-xr-xchrome/common/extensions/docs/server2/local_file_system_test.py4
-rwxr-xr-xchrome/common/extensions/docs/server2/memcache_file_system_test.py5
-rwxr-xr-xchrome/common/extensions/docs/server2/samples_data_source_test.py5
-rwxr-xr-xchrome/common/extensions/docs/server2/subversion_file_system_test.py3
-rwxr-xr-xchrome/common/extensions/docs/server2/template_data_source_test.py5
-rw-r--r--tools/json_schema_compiler/idl_schema.py15
11 files changed, 46 insertions, 19 deletions
diff --git a/chrome/common/extensions/docs/server2/api_data_source_test.py b/chrome/common/extensions/docs/server2/api_data_source_test.py
index 046a213..b94ab80 100755
--- a/chrome/common/extensions/docs/server2/api_data_source_test.py
+++ b/chrome/common/extensions/docs/server2/api_data_source_test.py
@@ -5,6 +5,7 @@
import json
import os
+import sys
import unittest
from api_data_source import APIDataSource
@@ -19,7 +20,7 @@ class FakeSamplesDataSource:
class APIDataSourceTest(unittest.TestCase):
def setUp(self):
- self._base_path = os.path.join('test_data', 'test_json')
+ self._base_path = os.path.join(sys.path[0], 'test_data', 'test_json')
def _ReadLocalFile(self, filename):
with open(os.path.join(self._base_path, filename), 'r') as f:
diff --git a/chrome/common/extensions/docs/server2/branch_utility_test.py b/chrome/common/extensions/docs/server2/branch_utility_test.py
index 505d6b8..ccc92f5 100755
--- a/chrome/common/extensions/docs/server2/branch_utility_test.py
+++ b/chrome/common/extensions/docs/server2/branch_utility_test.py
@@ -3,17 +3,20 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import os
+import sys
+import unittest
+
from in_memory_object_store import InMemoryObjectStore
from branch_utility import BranchUtility
from fake_url_fetcher import FakeUrlFetcher
-import unittest
class BranchUtilityTest(unittest.TestCase):
def setUp(self):
self._branch_util = BranchUtility(
- 'branch_utility/first.json',
+ os.path.join('branch_utility', 'first.json'),
{ 'extensions': 'stable', 'apps': 'trunk' },
- FakeUrlFetcher('test_data'),
+ FakeUrlFetcher(os.path.join(sys.path[0], 'test_data')),
InMemoryObjectStore(''))
def testSplitChannelNameFromPath(self):
diff --git a/chrome/common/extensions/docs/server2/example_zipper_test.py b/chrome/common/extensions/docs/server2/example_zipper_test.py
index eaf4744..f1a5185 100755
--- a/chrome/common/extensions/docs/server2/example_zipper_test.py
+++ b/chrome/common/extensions/docs/server2/example_zipper_test.py
@@ -4,6 +4,7 @@
# found in the LICENSE file.
import os
+import sys
import unittest
from compiled_file_system import CompiledFileSystem
@@ -15,8 +16,9 @@ from memcache_file_system import MemcacheFileSystem
class ExampleZipperTest(unittest.TestCase):
def setUp(self):
object_store = InMemoryObjectStore('')
- self._file_system = MemcacheFileSystem(LocalFileSystem('test_data'),
- object_store)
+ self._file_system = MemcacheFileSystem(
+ LocalFileSystem(os.path.join(sys.path[0], 'test_data')),
+ object_store)
self._example_zipper = ExampleZipper(
self._file_system,
CompiledFileSystem.Factory(self._file_system, object_store),
diff --git a/chrome/common/extensions/docs/server2/github_file_system_test.py b/chrome/common/extensions/docs/server2/github_file_system_test.py
index 34bc99e..8aeb77f 100755
--- a/chrome/common/extensions/docs/server2/github_file_system_test.py
+++ b/chrome/common/extensions/docs/server2/github_file_system_test.py
@@ -5,6 +5,7 @@
import json
import os
+import sys
import unittest
from appengine_blobstore import AppEngineBlobstore
@@ -17,8 +18,10 @@ import url_constants
class GithubFileSystemTest(unittest.TestCase):
def setUp(self):
- ConfigureFakeFetchers('.')
- self._base_path = os.path.join('test_data', 'github_file_system')
+ ConfigureFakeFetchers(sys.path[0])
+ self._base_path = os.path.join(sys.path[0],
+ 'test_data',
+ 'github_file_system')
self._file_system = GithubFileSystem(
AppEngineUrlFetcher(url_constants.GITHUB_URL),
InMemoryObjectStore('github'),
diff --git a/chrome/common/extensions/docs/server2/handlebar_dict_generator_test.py b/chrome/common/extensions/docs/server2/handlebar_dict_generator_test.py
index 2d43fc5..736fdfb 100755
--- a/chrome/common/extensions/docs/server2/handlebar_dict_generator_test.py
+++ b/chrome/common/extensions/docs/server2/handlebar_dict_generator_test.py
@@ -5,6 +5,7 @@
import json
import os
+import sys
import unittest
from docs_server_utils import GetLinkToRefType
@@ -23,7 +24,7 @@ def _GetType(dict_, name):
class DictGeneratorTest(unittest.TestCase):
def setUp(self):
- self._base_path = os.path.join('test_data', 'test_json')
+ self._base_path = os.path.join(sys.path[0], 'test_data', 'test_json')
def _ReadLocalFile(self, filename):
with open(os.path.join(self._base_path, filename), 'r') as f:
diff --git a/chrome/common/extensions/docs/server2/local_file_system_test.py b/chrome/common/extensions/docs/server2/local_file_system_test.py
index 70e1b05..d9f8b49 100755
--- a/chrome/common/extensions/docs/server2/local_file_system_test.py
+++ b/chrome/common/extensions/docs/server2/local_file_system_test.py
@@ -4,13 +4,15 @@
# found in the LICENSE file.
import os
+import sys
import unittest
from local_file_system import LocalFileSystem
class LocalFileSystemTest(unittest.TestCase):
def setUp(self):
- self._file_system = LocalFileSystem(os.path.join('test_data',
+ self._file_system = LocalFileSystem(os.path.join(sys.path[0],
+ 'test_data',
'file_system'))
def testReadFiles(self):
diff --git a/chrome/common/extensions/docs/server2/memcache_file_system_test.py b/chrome/common/extensions/docs/server2/memcache_file_system_test.py
index 712fe65..85b26e9 100755
--- a/chrome/common/extensions/docs/server2/memcache_file_system_test.py
+++ b/chrome/common/extensions/docs/server2/memcache_file_system_test.py
@@ -4,6 +4,7 @@
# found in the LICENSE file.
import os
+import sys
import unittest
import object_store
@@ -42,7 +43,9 @@ class _FakeFileSystem(FileSystem):
class MemcacheFileSystemTest(unittest.TestCase):
def setUp(self):
self._object_store = InMemoryObjectStore('')
- self._local_fs = LocalFileSystem(os.path.join('test_data', 'file_system'))
+ self._local_fs = LocalFileSystem(os.path.join(sys.path[0],
+ 'test_data',
+ 'file_system'))
def _SetReadCacheItem(self, key, value, stat):
self._object_store.Set(key, (value, stat), object_store.FILE_SYSTEM_READ)
diff --git a/chrome/common/extensions/docs/server2/samples_data_source_test.py b/chrome/common/extensions/docs/server2/samples_data_source_test.py
index cfcbd1f..1136065 100755
--- a/chrome/common/extensions/docs/server2/samples_data_source_test.py
+++ b/chrome/common/extensions/docs/server2/samples_data_source_test.py
@@ -5,13 +5,16 @@
import json
import os
+import sys
import unittest
from samples_data_source import SamplesDataSource
class SamplesDataSourceTest(unittest.TestCase):
def setUp(self):
- self._base_path = os.path.join('test_data', 'samples_data_source')
+ self._base_path = os.path.join(sys.path[0],
+ 'test_data',
+ 'samples_data_source')
def _ReadLocalFile(self, filename):
with open(os.path.join(self._base_path, filename), 'r') as f:
diff --git a/chrome/common/extensions/docs/server2/subversion_file_system_test.py b/chrome/common/extensions/docs/server2/subversion_file_system_test.py
index 370640b..8a78268 100755
--- a/chrome/common/extensions/docs/server2/subversion_file_system_test.py
+++ b/chrome/common/extensions/docs/server2/subversion_file_system_test.py
@@ -5,6 +5,7 @@
import json
import os
+import sys
import unittest
from fake_url_fetcher import FakeUrlFetcher
@@ -12,7 +13,7 @@ from subversion_file_system import SubversionFileSystem
class SubversionFileSystemTest(unittest.TestCase):
def setUp(self):
- self._base_path = os.path.join('test_data', 'file_system')
+ self._base_path = os.path.join(sys.path[0], 'test_data', 'file_system')
fetcher = FakeUrlFetcher(self._base_path)
self._file_system = SubversionFileSystem(fetcher, fetcher)
diff --git a/chrome/common/extensions/docs/server2/template_data_source_test.py b/chrome/common/extensions/docs/server2/template_data_source_test.py
index 872cc84..f2580ce 100755
--- a/chrome/common/extensions/docs/server2/template_data_source_test.py
+++ b/chrome/common/extensions/docs/server2/template_data_source_test.py
@@ -5,6 +5,7 @@
import json
import os
+import sys
import unittest
from in_memory_object_store import InMemoryObjectStore
@@ -28,7 +29,9 @@ class _FakeFactory(object):
class TemplateDataSourceTest(unittest.TestCase):
def setUp(self):
- self._base_path = os.path.join('test_data', 'template_data_source')
+ self._base_path = os.path.join(sys.path[0],
+ 'test_data',
+ 'template_data_source')
self._fake_api_data_source_factory = _FakeFactory()
self._fake_api_list_data_source_factory = _FakeFactory()
self._fake_intro_data_source_factory = _FakeFactory()
diff --git a/tools/json_schema_compiler/idl_schema.py b/tools/json_schema_compiler/idl_schema.py
index 393887b..6693ed4 100644
--- a/tools/json_schema_compiler/idl_schema.py
+++ b/tools/json_schema_compiler/idl_schema.py
@@ -20,11 +20,16 @@ import schema_util
# idl_parser expects to be able to import certain files in its directory,
# so let's set things up the way it wants.
-idl_generators_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
- os.pardir, os.pardir, 'ppapi', 'generators')
-if idl_generators_path not in sys.path:
- sys.path.insert(0, idl_generators_path)
-import idl_parser
+_idl_generators_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
+ os.pardir, os.pardir, 'ppapi', 'generators')
+if _idl_generators_path in sys.path:
+ import idl_parser
+else:
+ sys.path.insert(0, _idl_generators_path)
+ try:
+ import idl_parser
+ finally:
+ sys.path.pop(0)
def ProcessComment(comment):
'''