summaryrefslogtreecommitdiff
path: root/tests/test_config
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2018-10-14 23:16:48 -0500
committerMichael Merickel <michael@merickel.org>2018-10-14 23:46:11 -0500
commitdd3cc81f75dcb5ff96e0751653071722a15f46c2 (patch)
tree7cfd6140211a21dedd2ddfeb4aa77b7ff4339fa9 /tests/test_config
parenteadaee315eb142d1537d617da58343e3d7f1df0a (diff)
downloadpyramid-dd3cc81f75dcb5ff96e0751653071722a15f46c2.tar.gz
pyramid-dd3cc81f75dcb5ff96e0751653071722a15f46c2.tar.bz2
pyramid-dd3cc81f75dcb5ff96e0751653071722a15f46c2.zip
fix the tests to import from the tests package instead of pyramid.tests
Diffstat (limited to 'tests/test_config')
-rw-r--r--tests/test_config/test_adapters.py18
-rw-r--r--tests/test_config/test_assets.py134
-rw-r--r--tests/test_config/test_factories.py10
-rw-r--r--tests/test_config/test_i18n.py44
-rw-r--r--tests/test_config/test_init.py169
-rw-r--r--tests/test_config/test_rendering.py6
-rw-r--r--tests/test_config/test_routes.py6
-rw-r--r--tests/test_config/test_testing.py4
-rw-r--r--tests/test_config/test_tweens.py46
-rw-r--r--tests/test_config/test_views.py60
10 files changed, 248 insertions, 249 deletions
diff --git a/tests/test_config/test_adapters.py b/tests/test_config/test_adapters.py
index ab5d6ef61..e554520e7 100644
--- a/tests/test_config/test_adapters.py
+++ b/tests/test_config/test_adapters.py
@@ -1,7 +1,7 @@
import unittest
from pyramid.compat import PY2
-from pyramid.tests.test_config import IDummy
+from . import IDummy
class AdaptersConfiguratorMixinTests(unittest.TestCase):
def _makeOne(self, *arg, **kw):
@@ -50,15 +50,15 @@ class AdaptersConfiguratorMixinTests(unittest.TestCase):
self.assertEqual(len(L), 1)
def test_add_subscriber_dottednames(self):
- import pyramid.tests.test_config
+ import tests.test_config
from pyramid.interfaces import INewRequest
config = self._makeOne(autocommit=True)
- config.add_subscriber('pyramid.tests.test_config',
+ config.add_subscriber('tests.test_config',
'pyramid.interfaces.INewRequest')
handlers = list(config.registry.registeredHandlers())
self.assertEqual(len(handlers), 1)
handler = handlers[0]
- self.assertEqual(handler.handler, pyramid.tests.test_config)
+ self.assertEqual(handler.handler, tests.test_config)
self.assertEqual(handler.required, (INewRequest,))
def test_add_object_event_subscriber(self):
@@ -231,8 +231,8 @@ class AdaptersConfiguratorMixinTests(unittest.TestCase):
from pyramid.interfaces import ITraverser
config = self._makeOne(autocommit=True)
config.add_traverser(
- 'pyramid.tests.test_config.test_adapters.DummyTraverser',
- 'pyramid.tests.test_config.test_adapters.DummyIface')
+ 'tests.test_config.test_adapters.DummyTraverser',
+ 'tests.test_config.test_adapters.DummyIface')
iface = DummyIface()
traverser = config.registry.getAdapter(iface, ITraverser)
self.assertEqual(traverser.__class__, DummyTraverser)
@@ -273,8 +273,8 @@ class AdaptersConfiguratorMixinTests(unittest.TestCase):
from pyramid.interfaces import IResourceURL
config = self._makeOne(autocommit=True)
config.add_resource_url_adapter(
- 'pyramid.tests.test_config.test_adapters.DummyResourceURL',
- 'pyramid.tests.test_config.test_adapters.DummyIface',
+ 'tests.test_config.test_adapters.DummyResourceURL',
+ 'tests.test_config.test_adapters.DummyIface',
)
iface = DummyIface()
adapter = config.registry.getMultiAdapter((iface, iface),
@@ -326,7 +326,7 @@ class AdaptersConfiguratorMixinTests(unittest.TestCase):
self.assertEqual(
intr.title,
"resource url adapter for resource iface "
- "<class 'pyramid.tests.test_config.test_adapters.DummyIface'>"
+ "<class 'tests.test_config.test_adapters.DummyIface'>"
)
self.assertEqual(intr['adapter'], DummyResourceURL)
self.assertEqual(intr['resource_iface'], DummyIface)
diff --git a/tests/test_config/test_assets.py b/tests/test_config/test_assets.py
index 842c73da6..b16977b99 100644
--- a/tests/test_config/test_assets.py
+++ b/tests/test_config/test_assets.py
@@ -21,32 +21,32 @@ class TestAssetsConfiguratorMixin(unittest.TestCase):
config = self._makeOne()
self.assertRaises(ConfigurationError, config.override_asset,
'a:foo/',
- 'pyramid.tests.test_config.pkgs.asset:foo.pt')
+ 'tests.test_config.pkgs.asset:foo.pt')
def test_override_asset_file_with_directory(self):
from pyramid.exceptions import ConfigurationError
config = self._makeOne()
self.assertRaises(ConfigurationError, config.override_asset,
'a:foo.pt',
- 'pyramid.tests.test_config.pkgs.asset:templates/')
+ 'tests.test_config.pkgs.asset:templates/')
def test_override_asset_file_with_package(self):
from pyramid.exceptions import ConfigurationError
config = self._makeOne()
self.assertRaises(ConfigurationError, config.override_asset,
'a:foo.pt',
- 'pyramid.tests.test_config.pkgs.asset')
+ 'tests.test_config.pkgs.asset')
def test_override_asset_file_with_file(self):
from pyramid.config.assets import PackageAssetSource
config = self._makeOne(autocommit=True)
override = DummyUnderOverride()
config.override_asset(
- 'pyramid.tests.test_config.pkgs.asset:templates/foo.pt',
- 'pyramid.tests.test_config.pkgs.asset.subpackage:templates/bar.pt',
+ 'tests.test_config.pkgs.asset:templates/foo.pt',
+ 'tests.test_config.pkgs.asset.subpackage:templates/bar.pt',
_override=override)
- from pyramid.tests.test_config.pkgs import asset
- from pyramid.tests.test_config.pkgs.asset import subpackage
+ from tests.test_config.pkgs import asset
+ from tests.test_config.pkgs.asset import subpackage
self.assertEqual(override.package, asset)
self.assertEqual(override.path, 'templates/foo.pt')
source = override.source
@@ -65,11 +65,11 @@ class TestAssetsConfiguratorMixin(unittest.TestCase):
config = self._makeOne(autocommit=True)
override = DummyUnderOverride()
config.override_asset(
- 'pyramid.tests.test_config.pkgs.asset',
- 'pyramid.tests.test_config.pkgs.asset.subpackage',
+ 'tests.test_config.pkgs.asset',
+ 'tests.test_config.pkgs.asset.subpackage',
_override=override)
- from pyramid.tests.test_config.pkgs import asset
- from pyramid.tests.test_config.pkgs.asset import subpackage
+ from tests.test_config.pkgs import asset
+ from tests.test_config.pkgs.asset import subpackage
self.assertEqual(override.package, asset)
self.assertEqual(override.path, '')
source = override.source
@@ -88,11 +88,11 @@ class TestAssetsConfiguratorMixin(unittest.TestCase):
config = self._makeOne(autocommit=True)
override = DummyUnderOverride()
config.override_asset(
- 'pyramid.tests.test_config.pkgs.asset:templates/',
- 'pyramid.tests.test_config.pkgs.asset.subpackage:templates/',
+ 'tests.test_config.pkgs.asset:templates/',
+ 'tests.test_config.pkgs.asset.subpackage:templates/',
_override=override)
- from pyramid.tests.test_config.pkgs import asset
- from pyramid.tests.test_config.pkgs.asset import subpackage
+ from tests.test_config.pkgs import asset
+ from tests.test_config.pkgs.asset import subpackage
self.assertEqual(override.package, asset)
self.assertEqual(override.path, 'templates/')
source = override.source
@@ -111,11 +111,11 @@ class TestAssetsConfiguratorMixin(unittest.TestCase):
config = self._makeOne(autocommit=True)
override = DummyUnderOverride()
config.override_asset(
- 'pyramid.tests.test_config.pkgs.asset:templates/',
- 'pyramid.tests.test_config.pkgs.asset.subpackage',
+ 'tests.test_config.pkgs.asset:templates/',
+ 'tests.test_config.pkgs.asset.subpackage',
_override=override)
- from pyramid.tests.test_config.pkgs import asset
- from pyramid.tests.test_config.pkgs.asset import subpackage
+ from tests.test_config.pkgs import asset
+ from tests.test_config.pkgs.asset import subpackage
self.assertEqual(override.package, asset)
self.assertEqual(override.path, 'templates/')
source = override.source
@@ -134,11 +134,11 @@ class TestAssetsConfiguratorMixin(unittest.TestCase):
config = self._makeOne(autocommit=True)
override = DummyUnderOverride()
config.override_asset(
- 'pyramid.tests.test_config.pkgs.asset',
- 'pyramid.tests.test_config.pkgs.asset.subpackage:templates/',
+ 'tests.test_config.pkgs.asset',
+ 'tests.test_config.pkgs.asset.subpackage:templates/',
_override=override)
- from pyramid.tests.test_config.pkgs import asset
- from pyramid.tests.test_config.pkgs.asset import subpackage
+ from tests.test_config.pkgs import asset
+ from tests.test_config.pkgs.asset import subpackage
self.assertEqual(override.package, asset)
self.assertEqual(override.path, '')
source = override.source
@@ -181,10 +181,10 @@ class TestAssetsConfiguratorMixin(unittest.TestCase):
abspath = os.path.join(here, 'pkgs', 'asset', 'subpackage',
'templates', 'bar.pt')
config.override_asset(
- 'pyramid.tests.test_config.pkgs.asset:templates/foo.pt',
+ 'tests.test_config.pkgs.asset:templates/foo.pt',
abspath,
_override=override)
- from pyramid.tests.test_config.pkgs import asset
+ from tests.test_config.pkgs import asset
self.assertEqual(override.package, asset)
self.assertEqual(override.path, 'templates/foo.pt')
source = override.source
@@ -203,10 +203,10 @@ class TestAssetsConfiguratorMixin(unittest.TestCase):
override = DummyUnderOverride()
abspath = os.path.join(here, 'pkgs', 'asset', 'subpackage', 'templates')
config.override_asset(
- 'pyramid.tests.test_config.pkgs.asset:templates/',
+ 'tests.test_config.pkgs.asset:templates/',
abspath,
_override=override)
- from pyramid.tests.test_config.pkgs import asset
+ from tests.test_config.pkgs import asset
self.assertEqual(override.package, asset)
self.assertEqual(override.path, 'templates/')
source = override.source
@@ -225,10 +225,10 @@ class TestAssetsConfiguratorMixin(unittest.TestCase):
override = DummyUnderOverride()
abspath = os.path.join(here, 'pkgs', 'asset', 'subpackage', 'templates')
config.override_asset(
- 'pyramid.tests.test_config.pkgs.asset',
+ 'tests.test_config.pkgs.asset',
abspath,
_override=override)
- from pyramid.tests.test_config.pkgs import asset
+ from tests.test_config.pkgs import asset
self.assertEqual(override.package, asset)
self.assertEqual(override.path, '')
source = override.source
@@ -282,7 +282,7 @@ class TestOverrideProvider(unittest.TestCase):
klass = self._getTargetClass()
return klass(module)
- def _registerOverrides(self, overrides, name='pyramid.tests.test_config'):
+ def _registerOverrides(self, overrides, name='tests.test_config'):
from pyramid.interfaces import IPackageOverrides
from pyramid.threadlocal import get_current_registry
reg = get_current_registry()
@@ -290,38 +290,38 @@ class TestOverrideProvider(unittest.TestCase):
def test_get_resource_filename_no_overrides(self):
resource_name = 'test_assets.py'
- import pyramid.tests.test_config
- provider = self._makeOne(pyramid.tests.test_config)
+ import tests.test_config
+ provider = self._makeOne(tests.test_config)
expected = os.path.join(here, resource_name)
result = provider.get_resource_filename(None, resource_name)
self.assertEqual(result, expected)
def test_get_resource_stream_no_overrides(self):
resource_name = 'test_assets.py'
- import pyramid.tests.test_config
- provider = self._makeOne(pyramid.tests.test_config)
+ import tests.test_config
+ provider = self._makeOne(tests.test_config)
with provider.get_resource_stream(None, resource_name) as result:
_assertBody(result.read(), os.path.join(here, resource_name))
def test_get_resource_string_no_overrides(self):
resource_name = 'test_assets.py'
- import pyramid.tests.test_config
- provider = self._makeOne(pyramid.tests.test_config)
+ import tests.test_config
+ provider = self._makeOne(tests.test_config)
result = provider.get_resource_string(None, resource_name)
_assertBody(result, os.path.join(here, resource_name))
def test_has_resource_no_overrides(self):
resource_name = 'test_assets.py'
- import pyramid.tests.test_config
- provider = self._makeOne(pyramid.tests.test_config)
+ import tests.test_config
+ provider = self._makeOne(tests.test_config)
result = provider.has_resource(resource_name)
self.assertEqual(result, True)
def test_resource_isdir_no_overrides(self):
file_resource_name = 'test_assets.py'
directory_resource_name = 'files'
- import pyramid.tests.test_config
- provider = self._makeOne(pyramid.tests.test_config)
+ import tests.test_config
+ provider = self._makeOne(tests.test_config)
result = provider.resource_isdir(file_resource_name)
self.assertEqual(result, False)
result = provider.resource_isdir(directory_resource_name)
@@ -329,8 +329,8 @@ class TestOverrideProvider(unittest.TestCase):
def test_resource_listdir_no_overrides(self):
resource_name = 'files'
- import pyramid.tests.test_config
- provider = self._makeOne(pyramid.tests.test_config)
+ import tests.test_config
+ provider = self._makeOne(tests.test_config)
result = provider.resource_listdir(resource_name)
self.assertTrue(result)
@@ -338,8 +338,8 @@ class TestOverrideProvider(unittest.TestCase):
overrides = DummyOverrides(None)
self._registerOverrides(overrides)
resource_name = 'test_assets.py'
- import pyramid.tests.test_config
- provider = self._makeOne(pyramid.tests.test_config)
+ import tests.test_config
+ provider = self._makeOne(tests.test_config)
expected = os.path.join(here, resource_name)
result = provider.get_resource_filename(None, resource_name)
self.assertEqual(result, expected)
@@ -348,8 +348,8 @@ class TestOverrideProvider(unittest.TestCase):
overrides = DummyOverrides(None)
self._registerOverrides(overrides)
resource_name = 'test_assets.py'
- import pyramid.tests.test_config
- provider = self._makeOne(pyramid.tests.test_config)
+ import tests.test_config
+ provider = self._makeOne(tests.test_config)
with provider.get_resource_stream(None, resource_name) as result:
_assertBody(result.read(), os.path.join(here, resource_name))
@@ -357,8 +357,8 @@ class TestOverrideProvider(unittest.TestCase):
overrides = DummyOverrides(None)
self._registerOverrides(overrides)
resource_name = 'test_assets.py'
- import pyramid.tests.test_config
- provider = self._makeOne(pyramid.tests.test_config)
+ import tests.test_config
+ provider = self._makeOne(tests.test_config)
result = provider.get_resource_string(None, resource_name)
_assertBody(result, os.path.join(here, resource_name))
@@ -366,8 +366,8 @@ class TestOverrideProvider(unittest.TestCase):
overrides = DummyOverrides(None)
self._registerOverrides(overrides)
resource_name = 'test_assets.py'
- import pyramid.tests.test_config
- provider = self._makeOne(pyramid.tests.test_config)
+ import tests.test_config
+ provider = self._makeOne(tests.test_config)
result = provider.has_resource(resource_name)
self.assertEqual(result, True)
@@ -375,8 +375,8 @@ class TestOverrideProvider(unittest.TestCase):
overrides = DummyOverrides(None)
self._registerOverrides(overrides)
resource_name = 'files'
- import pyramid.tests.test_config
- provider = self._makeOne(pyramid.tests.test_config)
+ import tests.test_config
+ provider = self._makeOne(tests.test_config)
result = provider.resource_isdir(resource_name)
self.assertEqual(result, True)
@@ -384,57 +384,57 @@ class TestOverrideProvider(unittest.TestCase):
overrides = DummyOverrides(None)
self._registerOverrides(overrides)
resource_name = 'files'
- import pyramid.tests.test_config
- provider = self._makeOne(pyramid.tests.test_config)
+ import tests.test_config
+ provider = self._makeOne(tests.test_config)
result = provider.resource_listdir(resource_name)
self.assertTrue(result)
def test_get_resource_filename_override_returns_value(self):
overrides = DummyOverrides('value')
- import pyramid.tests.test_config
+ import tests.test_config
self._registerOverrides(overrides)
- provider = self._makeOne(pyramid.tests.test_config)
+ provider = self._makeOne(tests.test_config)
result = provider.get_resource_filename(None, 'test_assets.py')
self.assertEqual(result, 'value')
def test_get_resource_stream_override_returns_value(self):
from io import BytesIO
overrides = DummyOverrides(BytesIO(b'value'))
- import pyramid.tests.test_config
+ import tests.test_config
self._registerOverrides(overrides)
- provider = self._makeOne(pyramid.tests.test_config)
+ provider = self._makeOne(tests.test_config)
with provider.get_resource_stream(None, 'test_assets.py') as stream:
self.assertEqual(stream.getvalue(), b'value')
def test_get_resource_string_override_returns_value(self):
overrides = DummyOverrides('value')
- import pyramid.tests.test_config
+ import tests.test_config
self._registerOverrides(overrides)
- provider = self._makeOne(pyramid.tests.test_config)
+ provider = self._makeOne(tests.test_config)
result = provider.get_resource_string(None, 'test_assets.py')
self.assertEqual(result, 'value')
def test_has_resource_override_returns_True(self):
overrides = DummyOverrides(True)
- import pyramid.tests.test_config
+ import tests.test_config
self._registerOverrides(overrides)
- provider = self._makeOne(pyramid.tests.test_config)
+ provider = self._makeOne(tests.test_config)
result = provider.has_resource('test_assets.py')
self.assertEqual(result, True)
def test_resource_isdir_override_returns_False(self):
overrides = DummyOverrides(False)
- import pyramid.tests.test_config
+ import tests.test_config
self._registerOverrides(overrides)
- provider = self._makeOne(pyramid.tests.test_config)
+ provider = self._makeOne(tests.test_config)
result = provider.resource_isdir('files')
self.assertEqual(result, False)
def test_resource_listdir_override_returns_values(self):
overrides = DummyOverrides(['a'])
- import pyramid.tests.test_config
+ import tests.test_config
self._registerOverrides(overrides)
- provider = self._makeOne(pyramid.tests.test_config)
+ provider = self._makeOne(tests.test_config)
result = provider.resource_listdir('files')
self.assertEqual(result, ['a'])
@@ -791,7 +791,7 @@ class TestPackageAssetSource(AssetSourceIntegrationTests, unittest.TestCase):
from pyramid.config.assets import PackageAssetSource
return PackageAssetSource
- def _makeOne(self, prefix, package='pyramid.tests.test_config'):
+ def _makeOne(self, prefix, package='tests.test_config'):
klass = self._getTargetClass()
return klass(package, prefix)
diff --git a/tests/test_config/test_factories.py b/tests/test_config/test_factories.py
index 7e6ea0476..ea8dec720 100644
--- a/tests/test_config/test_factories.py
+++ b/tests/test_config/test_factories.py
@@ -1,6 +1,6 @@
import unittest
-from pyramid.tests.test_config import dummyfactory
+from . import dummyfactory
class TestFactoriesMixin(unittest.TestCase):
def _makeOne(self, *arg, **kw):
@@ -19,7 +19,7 @@ class TestFactoriesMixin(unittest.TestCase):
from pyramid.interfaces import IRequestFactory
config = self._makeOne(autocommit=True)
config.set_request_factory(
- 'pyramid.tests.test_config.dummyfactory')
+ 'tests.test_config.dummyfactory')
self.assertEqual(config.registry.getUtility(IRequestFactory),
dummyfactory)
@@ -34,7 +34,7 @@ class TestFactoriesMixin(unittest.TestCase):
from pyramid.interfaces import IResponseFactory
config = self._makeOne(autocommit=True)
config.set_response_factory(
- 'pyramid.tests.test_config.dummyfactory')
+ 'tests.test_config.dummyfactory')
self.assertEqual(config.registry.getUtility(IResponseFactory),
dummyfactory)
@@ -59,7 +59,7 @@ class TestFactoriesMixin(unittest.TestCase):
def test_set_root_factory_dottedname(self):
from pyramid.interfaces import IRootFactory
config = self._makeOne()
- config.set_root_factory('pyramid.tests.test_config.dummyfactory')
+ config.set_root_factory('tests.test_config.dummyfactory')
self.assertEqual(config.registry.queryUtility(IRootFactory), None)
config.commit()
self.assertEqual(config.registry.getUtility(IRootFactory), dummyfactory)
@@ -76,7 +76,7 @@ class TestFactoriesMixin(unittest.TestCase):
def test_set_session_factory_dottedname(self):
from pyramid.interfaces import ISessionFactory
config = self._makeOne()
- config.set_session_factory('pyramid.tests.test_config.dummyfactory')
+ config.set_session_factory('tests.test_config.dummyfactory')
self.assertEqual(config.registry.queryUtility(ISessionFactory), None)
config.commit()
self.assertEqual(config.registry.getUtility(ISessionFactory),
diff --git a/tests/test_config/test_i18n.py b/tests/test_config/test_i18n.py
index c10ab6bdb..87805f671 100644
--- a/tests/test_config/test_i18n.py
+++ b/tests/test_config/test_i18n.py
@@ -1,7 +1,7 @@
import os
import unittest
-from pyramid.tests.test_config import dummyfactory
+from . import dummyfactory
here = os.path.dirname(__file__)
locale = os.path.abspath(
@@ -29,7 +29,7 @@ class TestI18NConfiguratorMixin(unittest.TestCase):
from pyramid.interfaces import ILocaleNegotiator
config = self._makeOne(autocommit=True)
config.set_locale_negotiator(
- 'pyramid.tests.test_config.dummyfactory')
+ 'tests.test_config.dummyfactory')
self.assertEqual(config.registry.getUtility(ILocaleNegotiator),
dummyfactory)
@@ -49,7 +49,7 @@ class TestI18NConfiguratorMixin(unittest.TestCase):
def test_add_translation_dirs_asset_spec(self):
from pyramid.interfaces import ITranslationDirectories
config = self._makeOne(autocommit=True)
- config.add_translation_dirs('pyramid.tests.pkgs.localeapp:locale')
+ config.add_translation_dirs('tests.pkgs.localeapp:locale')
self.assertEqual(config.registry.getUtility(ITranslationDirectories),
[locale])
@@ -58,33 +58,33 @@ class TestI18NConfiguratorMixin(unittest.TestCase):
config = self._makeOne(autocommit=True)
directories = ['abc']
config.registry.registerUtility(directories, ITranslationDirectories)
- config.add_translation_dirs('pyramid.tests.pkgs.localeapp:locale')
+ config.add_translation_dirs('tests.pkgs.localeapp:locale')
result = config.registry.getUtility(ITranslationDirectories)
self.assertEqual(result, [locale, 'abc'])
def test_add_translation_dirs_multiple_specs(self):
from pyramid.interfaces import ITranslationDirectories
config = self._makeOne(autocommit=True)
- config.add_translation_dirs('pyramid.tests.pkgs.localeapp:locale',
- 'pyramid.tests.pkgs.localeapp:locale2')
+ config.add_translation_dirs('tests.pkgs.localeapp:locale',
+ 'tests.pkgs.localeapp:locale2')
self.assertEqual(config.registry.getUtility(ITranslationDirectories),
[locale, locale2])
def test_add_translation_dirs_multiple_specs_multiple_calls(self):
from pyramid.interfaces import ITranslationDirectories
config = self._makeOne(autocommit=True)
- config.add_translation_dirs('pyramid.tests.pkgs.localeapp:locale',
- 'pyramid.tests.pkgs.localeapp:locale2')
- config.add_translation_dirs('pyramid.tests.pkgs.localeapp:locale3')
+ config.add_translation_dirs('tests.pkgs.localeapp:locale',
+ 'tests.pkgs.localeapp:locale2')
+ config.add_translation_dirs('tests.pkgs.localeapp:locale3')
self.assertEqual(config.registry.getUtility(ITranslationDirectories),
[locale3, locale, locale2])
def test_add_translation_dirs_override_multiple_specs_multiple_calls(self):
from pyramid.interfaces import ITranslationDirectories
config = self._makeOne(autocommit=True)
- config.add_translation_dirs('pyramid.tests.pkgs.localeapp:locale',
- 'pyramid.tests.pkgs.localeapp:locale2')
- config.add_translation_dirs('pyramid.tests.pkgs.localeapp:locale3',
+ config.add_translation_dirs('tests.pkgs.localeapp:locale',
+ 'tests.pkgs.localeapp:locale2')
+ config.add_translation_dirs('tests.pkgs.localeapp:locale3',
override=True)
self.assertEqual(config.registry.getUtility(ITranslationDirectories),
[locale, locale2, locale3])
@@ -93,7 +93,7 @@ class TestI18NConfiguratorMixin(unittest.TestCase):
from pyramid.interfaces import ITranslationDirectories
config = self._makeOne(autocommit=True)
with self.assertRaises(TypeError):
- config.add_translation_dirs('pyramid.tests.pkgs.localeapp:locale',
+ config.add_translation_dirs('tests.pkgs.localeapp:locale',
foo=1)
def test_add_translation_dirs_abspath(self):
@@ -106,9 +106,9 @@ class TestI18NConfiguratorMixin(unittest.TestCase):
def test_add_translation_dirs_uses_override_out_of_order(self):
from pyramid.interfaces import ITranslationDirectories
config = self._makeOne()
- config.add_translation_dirs('pyramid.tests.pkgs.localeapp:locale')
- config.override_asset('pyramid.tests.pkgs.localeapp:locale/',
- 'pyramid.tests.pkgs.localeapp:locale2/')
+ config.add_translation_dirs('tests.pkgs.localeapp:locale')
+ config.override_asset('tests.pkgs.localeapp:locale/',
+ 'tests.pkgs.localeapp:locale2/')
config.commit()
self.assertEqual(config.registry.getUtility(ITranslationDirectories),
[locale2])
@@ -116,17 +116,17 @@ class TestI18NConfiguratorMixin(unittest.TestCase):
def test_add_translation_dirs_doesnt_use_override_w_autocommit(self):
from pyramid.interfaces import ITranslationDirectories
config = self._makeOne(autocommit=True)
- config.add_translation_dirs('pyramid.tests.pkgs.localeapp:locale')
- config.override_asset('pyramid.tests.pkgs.localeapp:locale/',
- 'pyramid.tests.pkgs.localeapp:locale2/')
+ config.add_translation_dirs('tests.pkgs.localeapp:locale')
+ config.override_asset('tests.pkgs.localeapp:locale/',
+ 'tests.pkgs.localeapp:locale2/')
self.assertEqual(config.registry.getUtility(ITranslationDirectories),
[locale])
def test_add_translation_dirs_uses_override_w_autocommit(self):
from pyramid.interfaces import ITranslationDirectories
config = self._makeOne(autocommit=True)
- config.override_asset('pyramid.tests.pkgs.localeapp:locale/',
- 'pyramid.tests.pkgs.localeapp:locale2/')
- config.add_translation_dirs('pyramid.tests.pkgs.localeapp:locale')
+ config.override_asset('tests.pkgs.localeapp:locale/',
+ 'tests.pkgs.localeapp:locale2/')
+ config.add_translation_dirs('tests.pkgs.localeapp:locale')
self.assertEqual(config.registry.getUtility(ITranslationDirectories),
[locale2])
diff --git a/tests/test_config/test_init.py b/tests/test_config/test_init.py
index 76a3d703d..a3c83357e 100644
--- a/tests/test_config/test_init.py
+++ b/tests/test_config/test_init.py
@@ -5,12 +5,12 @@ import os
from pyramid.compat import im_func
from pyramid.testing import skip_on
-from pyramid.tests.test_config import dummy_tween_factory
-from pyramid.tests.test_config import dummy_include
-from pyramid.tests.test_config import dummy_extend
-from pyramid.tests.test_config import dummy_extend2
-from pyramid.tests.test_config import IDummy
-from pyramid.tests.test_config import DummyContext
+from . import dummy_tween_factory
+from . import dummy_include
+from . import dummy_extend
+from . import dummy_extend2
+from . import IDummy
+from . import DummyContext
from pyramid.exceptions import ConfigurationExecutionError
from pyramid.exceptions import ConfigurationConflictError
@@ -63,7 +63,7 @@ class ConfiguratorTests(unittest.TestCase):
from pyramid.config import Configurator
from pyramid.interfaces import IRendererFactory
config = Configurator()
- this_pkg = sys.modules['pyramid.tests.test_config']
+ this_pkg = sys.modules['tests.test_config']
self.assertTrue(config.registry.getUtility(ISettings))
self.assertEqual(config.package, this_pkg)
config.commit()
@@ -178,7 +178,7 @@ class ConfiguratorTests(unittest.TestCase):
from pyramid.interfaces import IDebugLogger
config = self._makeOne()
logger = config.registry.getUtility(IDebugLogger)
- self.assertEqual(logger.name, 'pyramid.tests.test_config')
+ self.assertEqual(logger.name, 'tests.test_config')
def test_ctor_noreg_debug_logger_non_None(self):
from pyramid.interfaces import IDebugLogger
@@ -294,28 +294,28 @@ class ConfiguratorTests(unittest.TestCase):
self.assertEqual(result, response)
def test_with_package_module(self):
- from pyramid.tests.test_config import test_init
- import pyramid.tests
+ from . import test_init
config = self._makeOne()
newconfig = config.with_package(test_init)
- self.assertEqual(newconfig.package, pyramid.tests.test_config)
+ import tests.test_config
+ self.assertEqual(newconfig.package, tests.test_config)
def test_with_package_package(self):
- import pyramid.tests.test_config
+ from tests import test_config
config = self._makeOne()
- newconfig = config.with_package(pyramid.tests.test_config)
- self.assertEqual(newconfig.package, pyramid.tests.test_config)
+ newconfig = config.with_package(test_config)
+ self.assertEqual(newconfig.package, test_config)
def test_with_package(self):
- import pyramid.tests
+ import tests
config = self._makeOne()
config.basepath = 'basepath'
config.info = 'info'
config.includepath = ('spec',)
config.autocommit = True
config.route_prefix = 'prefix'
- newconfig = config.with_package(pyramid.tests)
- self.assertEqual(newconfig.package, pyramid.tests)
+ newconfig = config.with_package(tests)
+ self.assertEqual(newconfig.package, tests)
self.assertEqual(newconfig.registry, config.registry)
self.assertEqual(newconfig.autocommit, True)
self.assertEqual(newconfig.route_prefix, 'prefix')
@@ -324,38 +324,38 @@ class ConfiguratorTests(unittest.TestCase):
self.assertEqual(newconfig.includepath, ('spec',))
def test_maybe_dotted_string_success(self):
- import pyramid.tests.test_config
+ import tests.test_config
config = self._makeOne()
- result = config.maybe_dotted('pyramid.tests.test_config')
- self.assertEqual(result, pyramid.tests.test_config)
+ result = config.maybe_dotted('tests.test_config')
+ self.assertEqual(result, tests.test_config)
def test_maybe_dotted_string_fail(self):
config = self._makeOne()
self.assertRaises(ImportError, config.maybe_dotted, 'cant.be.found')
def test_maybe_dotted_notstring_success(self):
- import pyramid.tests.test_config
+ import tests.test_config
config = self._makeOne()
- result = config.maybe_dotted(pyramid.tests.test_config)
- self.assertEqual(result, pyramid.tests.test_config)
+ result = config.maybe_dotted(tests.test_config)
+ self.assertEqual(result, tests.test_config)
def test_absolute_asset_spec_already_absolute(self):
- import pyramid.tests.test_config
- config = self._makeOne(package=pyramid.tests.test_config)
+ import tests.test_config
+ config = self._makeOne(package=tests.test_config)
result = config.absolute_asset_spec('already:absolute')
self.assertEqual(result, 'already:absolute')
def test_absolute_asset_spec_notastring(self):
- import pyramid.tests.test_config
- config = self._makeOne(package=pyramid.tests.test_config)
+ import tests.test_config
+ config = self._makeOne(package=tests.test_config)
result = config.absolute_asset_spec(None)
self.assertEqual(result, None)
def test_absolute_asset_spec_relative(self):
- import pyramid.tests.test_config
- config = self._makeOne(package=pyramid.tests.test_config)
+ import tests.test_config
+ config = self._makeOne(package=tests.test_config)
result = config.absolute_asset_spec('files')
- self.assertEqual(result, 'pyramid.tests.test_config:files')
+ self.assertEqual(result, 'tests.test_config:files')
def test__fix_registry_has_listeners(self):
reg = DummyRegistry()
@@ -498,7 +498,7 @@ class ConfiguratorTests(unittest.TestCase):
config = self._makeOne(reg)
config.setup_registry()
logger = reg.getUtility(IDebugLogger)
- self.assertEqual(logger.name, 'pyramid.tests.test_config')
+ self.assertEqual(logger.name, 'tests.test_config')
def test_setup_registry_debug_logger_non_None(self):
from pyramid.registry import Registry
@@ -535,11 +535,11 @@ class ConfiguratorTests(unittest.TestCase):
from pyramid.interfaces import IAuthenticationPolicy
reg = Registry()
config = self._makeOne(reg)
- config.setup_registry(authentication_policy='pyramid.tests.test_config')
+ config.setup_registry(authentication_policy='tests.test_config')
config.commit()
result = reg.getUtility(IAuthenticationPolicy)
- import pyramid.tests.test_config
- self.assertEqual(result, pyramid.tests.test_config)
+ import tests.test_config
+ self.assertEqual(result, tests.test_config)
def test_setup_registry_authorization_policy_dottedname(self):
from pyramid.registry import Registry
@@ -548,11 +548,11 @@ class ConfiguratorTests(unittest.TestCase):
config = self._makeOne(reg)
dummy = object()
config.setup_registry(authentication_policy=dummy,
- authorization_policy='pyramid.tests.test_config')
+ authorization_policy='tests.test_config')
config.commit()
result = reg.getUtility(IAuthorizationPolicy)
- import pyramid.tests.test_config
- self.assertEqual(result, pyramid.tests.test_config)
+ import tests.test_config
+ self.assertEqual(result, tests.test_config)
def test_setup_registry_authorization_policy_only(self):
from pyramid.registry import Registry
@@ -576,24 +576,23 @@ class ConfiguratorTests(unittest.TestCase):
from pyramid.interfaces import IRootFactory
reg = Registry()
config = self._makeOne(reg)
- import pyramid.tests.test_config
- config.setup_registry(root_factory='pyramid.tests.test_config')
+ import tests.test_config
+ config.setup_registry(root_factory='tests.test_config')
self.assertEqual(reg.queryUtility(IRootFactory), None)
config.commit()
- self.assertEqual(reg.getUtility(IRootFactory),
- pyramid.tests.test_config)
+ self.assertEqual(reg.getUtility(IRootFactory), tests.test_config)
def test_setup_registry_locale_negotiator_dottedname(self):
from pyramid.registry import Registry
from pyramid.interfaces import ILocaleNegotiator
reg = Registry()
config = self._makeOne(reg)
- import pyramid.tests.test_config
- config.setup_registry(locale_negotiator='pyramid.tests.test_config')
+ import tests.test_config
+ config.setup_registry(locale_negotiator='tests.test_config')
self.assertEqual(reg.queryUtility(ILocaleNegotiator), None)
config.commit()
utility = reg.getUtility(ILocaleNegotiator)
- self.assertEqual(utility, pyramid.tests.test_config)
+ self.assertEqual(utility, tests.test_config)
def test_setup_registry_locale_negotiator(self):
from pyramid.registry import Registry
@@ -636,12 +635,12 @@ class ConfiguratorTests(unittest.TestCase):
from pyramid.interfaces import IRequestFactory
reg = Registry()
config = self._makeOne(reg)
- import pyramid.tests.test_config
- config.setup_registry(request_factory='pyramid.tests.test_config')
+ import tests.test_config
+ config.setup_registry(request_factory='tests.test_config')
self.assertEqual(reg.queryUtility(IRequestFactory), None)
config.commit()
utility = reg.getUtility(IRequestFactory)
- self.assertEqual(utility, pyramid.tests.test_config)
+ self.assertEqual(utility, tests.test_config)
def test_setup_registry_alternate_renderers(self):
from pyramid.registry import Registry
@@ -669,8 +668,8 @@ class ConfiguratorTests(unittest.TestCase):
config = self._makeOne(reg)
settings = {
'pyramid.includes':
-"""pyramid.tests.test_config.dummy_include
-pyramid.tests.test_config.dummy_include2""",
+"""tests.test_config.dummy_include
+tests.test_config.dummy_include2""",
}
config.setup_registry(settings=settings)
self.assertTrue(reg.included)
@@ -682,7 +681,7 @@ pyramid.tests.test_config.dummy_include2""",
config = self._makeOne(reg)
settings = {
'pyramid.includes':
-"""pyramid.tests.test_config.dummy_include pyramid.tests.test_config.dummy_include2""",
+"""tests.test_config.dummy_include tests.test_config.dummy_include2""",
}
config.setup_registry(settings=settings)
self.assertTrue(reg.included)
@@ -695,14 +694,14 @@ pyramid.tests.test_config.dummy_include2""",
config = self._makeOne(reg)
settings = {
'pyramid.tweens':
- 'pyramid.tests.test_config.dummy_tween_factory'
+ 'tests.test_config.dummy_tween_factory'
}
config.setup_registry(settings=settings)
config.commit()
tweens = config.registry.getUtility(ITweens)
self.assertEqual(
tweens.explicit,
- [('pyramid.tests.test_config.dummy_tween_factory',
+ [('tests.test_config.dummy_tween_factory',
dummy_tween_factory)])
def test_introspector_decorator(self):
@@ -739,9 +738,9 @@ pyramid.tests.test_config.dummy_include2""",
pyramid.config.global_registries.empty()
def test_include_with_dotted_name(self):
- from pyramid.tests import test_config
+ from tests import test_config
config = self._makeOne()
- config.include('pyramid.tests.test_config.dummy_include')
+ config.include('tests.test_config.dummy_include')
after = config.action_state
actions = after.actions
self.assertEqual(len(actions), 1)
@@ -751,7 +750,7 @@ pyramid.tests.test_config.dummy_include2""",
self.assertEqual(action['args'], test_config)
def test_include_with_python_callable(self):
- from pyramid.tests import test_config
+ from tests import test_config
config = self._makeOne()
config.include(dummy_include)
after = config.action_state
@@ -763,9 +762,9 @@ pyramid.tests.test_config.dummy_include2""",
self.assertEqual(action['args'], test_config)
def test_include_with_module_defaults_to_includeme(self):
- from pyramid.tests import test_config
+ from tests import test_config
config = self._makeOne()
- config.include('pyramid.tests.test_config')
+ config.include('tests.test_config')
after = config.action_state
actions = after.actions
self.assertEqual(len(actions), 1)
@@ -777,7 +776,7 @@ pyramid.tests.test_config.dummy_include2""",
def test_include_with_module_defaults_to_includeme_missing(self):
from pyramid.exceptions import ConfigurationError
config = self._makeOne()
- self.assertRaises(ConfigurationError, config.include, 'pyramid.tests')
+ self.assertRaises(ConfigurationError, config.include, 'tests')
def test_include_with_route_prefix(self):
root_config = self._makeOne(autocommit=True)
@@ -812,18 +811,18 @@ pyramid.tests.test_config.dummy_include2""",
return None
config.inspect = DummyInspect()
try:
- config.include('pyramid.tests.test_config.dummy_include')
+ config.include('tests.test_config.dummy_include')
except ConfigurationError as e:
self.assertEqual(
e.args[0],
- "No source file for module 'pyramid.tests.test_config' (.py "
+ "No source file for module 'tests.test_config' (.py "
"file must exist, refusing to use orphan .pyc or .pyo file).")
else: # pragma: no cover
raise AssertionError
def test_include_constant_root_package(self):
- from pyramid import tests
- from pyramid.tests import test_config
+ import tests
+ from tests import test_config
config = self._makeOne(root_package=tests)
results = {}
def include(config):
@@ -834,8 +833,8 @@ pyramid.tests.test_config.dummy_include2""",
self.assertEqual(results['package'], test_config)
def test_include_threadlocals_active(self):
- from pyramid.tests import test_config
from pyramid.threadlocal import get_current_registry
+ from tests import test_config
stack = []
def include(config):
stack.append(get_current_registry())
@@ -935,7 +934,7 @@ pyramid.tests.test_config.dummy_include2""",
from zope.interface import alsoProvides
from pyramid.interfaces import IRequest
from pyramid.view import render_view_to_response
- import pyramid.tests.test_config.pkgs.scannable as package
+ import tests.test_config.pkgs.scannable as package
config = self._makeOne(autocommit=True)
config.scan(package)
@@ -1039,10 +1038,10 @@ pyramid.tests.test_config.dummy_include2""",
from zope.interface import alsoProvides
from pyramid.interfaces import IRequest
from pyramid.view import render_view_to_response
- import pyramid.tests.test_config.pkgs.scannable as package
+ import tests.test_config.pkgs.scannable as package
config = self._makeOne(autocommit=True)
config.scan(package,
- ignore='pyramid.tests.test_config.pkgs.scannable.another')
+ ignore='tests.test_config.pkgs.scannable.another')
ctx = DummyContext()
req = DummyRequest()
@@ -1062,7 +1061,7 @@ pyramid.tests.test_config.dummy_include2""",
from pyramid.interfaces import IRequest
from pyramid.view import render_view_to_response
config = self._makeOne(autocommit=True)
- config.scan('pyramid.tests.test_config.pkgs.scannable')
+ config.scan('tests.test_config.pkgs.scannable')
ctx = DummyContext()
req = DummyRequest()
@@ -1075,7 +1074,7 @@ pyramid.tests.test_config.dummy_include2""",
def test_scan_integration_with_extra_kw(self):
config = self._makeOne(autocommit=True)
- config.scan('pyramid.tests.test_config.pkgs.scanextrakw', a=1)
+ config.scan('tests.test_config.pkgs.scanextrakw', a=1)
self.assertEqual(config.a, 1)
def test_scan_integration_with_onerror(self):
@@ -1097,7 +1096,7 @@ pyramid.tests.test_config.dummy_include2""",
sys.path.remove(path)
def test_scan_integration_conflict(self):
- from pyramid.tests.test_config.pkgs import selfscan
+ from tests.test_config.pkgs import selfscan
from pyramid.config import Configurator
c = Configurator()
c.scan(selfscan)
@@ -1275,10 +1274,10 @@ class TestConfigurator_add_directive(unittest.TestCase):
self.config = Configurator()
def test_extend_with_dotted_name(self):
- from pyramid.tests import test_config
+ from tests import test_config
config = self.config
config.add_directive(
- 'dummy_extend', 'pyramid.tests.test_config.dummy_extend')
+ 'dummy_extend', 'tests.test_config.dummy_extend')
self.assertTrue(hasattr(config, 'dummy_extend'))
config.dummy_extend('discrim')
after = config.action_state
@@ -1288,10 +1287,10 @@ class TestConfigurator_add_directive(unittest.TestCase):
self.assertEqual(action['args'], test_config)
def test_add_directive_with_partial(self):
- from pyramid.tests import test_config
+ from tests import test_config
config = self.config
config.add_directive(
- 'dummy_partial', 'pyramid.tests.test_config.dummy_partial')
+ 'dummy_partial', 'tests.test_config.dummy_partial')
self.assertTrue(hasattr(config, 'dummy_partial'))
config.dummy_partial()
after = config.action_state
@@ -1301,10 +1300,10 @@ class TestConfigurator_add_directive(unittest.TestCase):
self.assertEqual(action['args'], test_config)
def test_add_directive_with_custom_callable(self):
- from pyramid.tests import test_config
+ from tests import test_config
config = self.config
config.add_directive(
- 'dummy_callable', 'pyramid.tests.test_config.dummy_callable')
+ 'dummy_callable', 'tests.test_config.dummy_callable')
self.assertTrue(hasattr(config, 'dummy_callable'))
config.dummy_callable('discrim')
after = config.action_state
@@ -1314,7 +1313,7 @@ class TestConfigurator_add_directive(unittest.TestCase):
self.assertEqual(action['args'], test_config)
def test_extend_with_python_callable(self):
- from pyramid.tests import test_config
+ from tests import test_config
config = self.config
config.add_directive(
'dummy_extend', dummy_extend)
@@ -1351,7 +1350,7 @@ class TestConfigurator_add_directive(unittest.TestCase):
def test_directive_persists_across_configurator_creations(self):
config = self.config
config.add_directive('dummy_extend', dummy_extend)
- config2 = config.with_package('pyramid.tests')
+ config2 = config.with_package('tests')
config2.dummy_extend('discrim')
after = config2.action_state
actions = after.actions
@@ -1391,7 +1390,7 @@ class TestConfigurator__add_predicate(unittest.TestCase):
config._add_predicate(
'route',
'testing',
- 'pyramid.tests.test_config.test_init.DummyPredicate'
+ 'tests.test_config.test_init.DummyPredicate'
)
class TestActionState(unittest.TestCase):
@@ -1404,7 +1403,7 @@ class TestActionState(unittest.TestCase):
self.assertEqual(c.actions, [])
def test_action_simple(self):
- from pyramid.tests.test_config import dummyfactory as f
+ from . import dummyfactory as f
c = self._makeOne()
c.actions = []
c.action(1, f, (1,), {'x':1})
@@ -1733,7 +1732,7 @@ class Test_resolveConflicts(unittest.TestCase):
return resolveConflicts(actions)
def test_it_success_tuples(self):
- from pyramid.tests.test_config import dummyfactory as f
+ from . import dummyfactory as f
result = self._callFUT([
(None, f),
(1, f, (1,), {}, (), 'first'),
@@ -1794,7 +1793,7 @@ class Test_resolveConflicts(unittest.TestCase):
)
def test_it_success_dicts(self):
- from pyramid.tests.test_config import dummyfactory as f
+ from . import dummyfactory as f
result = self._callFUT([
(None, f),
(1, f, (1,), {}, (), 'first'),
@@ -1855,7 +1854,7 @@ class Test_resolveConflicts(unittest.TestCase):
)
def test_it_conflict(self):
- from pyramid.tests.test_config import dummyfactory as f
+ from . import dummyfactory as f
result = self._callFUT([
(None, f),
(1, f, (2,), {}, ('x',), 'eek'), # will conflict
@@ -1867,7 +1866,7 @@ class Test_resolveConflicts(unittest.TestCase):
self.assertRaises(ConfigurationConflictError, list, result)
def test_it_with_actions_grouped_by_order(self):
- from pyramid.tests.test_config import dummyfactory as f
+ from . import dummyfactory as f
result = self._callFUT([
(None, f), # X
(1, f, (1,), {}, (), 'third', 10), # X
@@ -1941,7 +1940,7 @@ class Test_resolveConflicts(unittest.TestCase):
)
def test_override_success_across_orders(self):
- from pyramid.tests.test_config import dummyfactory as f
+ from . import dummyfactory as f
result = self._callFUT([
(1, f, (2,), {}, ('x',), 'eek', 0),
(1, f, (3,), {}, ('x', 'y'), 'ack', 10),
@@ -1959,7 +1958,7 @@ class Test_resolveConflicts(unittest.TestCase):
])
def test_conflicts_across_orders(self):
- from pyramid.tests.test_config import dummyfactory as f
+ from . import dummyfactory as f
result = self._callFUT([
(1, f, (2,), {}, ('x', 'y'), 'eek', 0),
(1, f, (3,), {}, ('x'), 'ack', 10),
diff --git a/tests/test_config/test_rendering.py b/tests/test_config/test_rendering.py
index cede64d3a..8794fa9df 100644
--- a/tests/test_config/test_rendering.py
+++ b/tests/test_config/test_rendering.py
@@ -27,8 +27,8 @@ class TestRenderingConfiguratorMixin(unittest.TestCase):
def test_add_renderer_dottedname_factory(self):
from pyramid.interfaces import IRendererFactory
config = self._makeOne(autocommit=True)
- import pyramid.tests.test_config
- config.add_renderer('name', 'pyramid.tests.test_config')
+ import tests.test_config
+ config.add_renderer('name', 'tests.test_config')
self.assertEqual(config.registry.getUtility(IRendererFactory, 'name'),
- pyramid.tests.test_config)
+ tests.test_config)
diff --git a/tests/test_config/test_routes.py b/tests/test_config/test_routes.py
index 9f4ce9bc6..870abe0ee 100644
--- a/tests/test_config/test_routes.py
+++ b/tests/test_config/test_routes.py
@@ -1,7 +1,7 @@
import unittest
-from pyramid.tests.test_config import dummyfactory
-from pyramid.tests.test_config import DummyContext
+from . import dummyfactory
+from . import DummyContext
from pyramid.compat import text_
class RoutesConfiguratorMixinTests(unittest.TestCase):
@@ -74,7 +74,7 @@ class RoutesConfiguratorMixinTests(unittest.TestCase):
config = self._makeOne(autocommit=True)
config.add_route(
'name', 'path',
- factory='pyramid.tests.test_config.dummyfactory')
+ factory='tests.test_config.dummyfactory')
route = self._assertRoute(config, 'name', 'path')
self.assertEqual(route.factory, dummyfactory)
diff --git a/tests/test_config/test_testing.py b/tests/test_config/test_testing.py
index 05561bfe9..5be4e48d3 100644
--- a/tests/test_config/test_testing.py
+++ b/tests/test_config/test_testing.py
@@ -2,7 +2,7 @@ import unittest
from pyramid.compat import text_
from pyramid.security import AuthenticationAPIMixin, AuthorizationAPIMixin
-from pyramid.tests.test_config import IDummy
+from . import IDummy
class TestingConfiguratorMixinTests(unittest.TestCase):
def _makeOne(self, *arg, **kw):
@@ -91,7 +91,7 @@ class TestingConfiguratorMixinTests(unittest.TestCase):
def test_testing_add_subscriber_dottedname(self):
config = self._makeOne(autocommit=True)
L = config.testing_add_subscriber(
- 'pyramid.tests.test_config.test_init.IDummy')
+ 'tests.test_config.test_init.IDummy')
event = DummyEvent()
config.registry.notify(event)
self.assertEqual(len(L), 1)
diff --git a/tests/test_config/test_tweens.py b/tests/test_config/test_tweens.py
index 9c3433468..25615c699 100644
--- a/tests/test_config/test_tweens.py
+++ b/tests/test_config/test_tweens.py
@@ -1,7 +1,7 @@
import unittest
-from pyramid.tests.test_config import dummy_tween_factory
-from pyramid.tests.test_config import dummy_tween_factory2
+from . import dummy_tween_factory
+from . import dummy_tween_factory2
from pyramid.exceptions import ConfigurationConflictError
@@ -18,18 +18,18 @@ class TestTweensConfiguratorMixin(unittest.TestCase):
def factory2(handler, registry): return handler
config = self._makeOne()
config.add_tween(
- 'pyramid.tests.test_config.dummy_tween_factory')
+ 'tests.test_config.dummy_tween_factory')
config.add_tween(
- 'pyramid.tests.test_config.dummy_tween_factory2')
+ 'tests.test_config.dummy_tween_factory2')
config.commit()
tweens = config.registry.queryUtility(ITweens)
implicit = tweens.implicit()
self.assertEqual(
implicit,
[
- ('pyramid.tests.test_config.dummy_tween_factory2',
+ ('tests.test_config.dummy_tween_factory2',
dummy_tween_factory2),
- ('pyramid.tests.test_config.dummy_tween_factory',
+ ('tests.test_config.dummy_tween_factory',
dummy_tween_factory),
('pyramid.tweens.excview_tween_factory',
excview_tween_factory),
@@ -42,12 +42,12 @@ class TestTweensConfiguratorMixin(unittest.TestCase):
from pyramid.tweens import MAIN
config = self._makeOne()
config.add_tween(
- 'pyramid.tests.test_config.dummy_tween_factory',
+ 'tests.test_config.dummy_tween_factory',
over=MAIN)
config.add_tween(
- 'pyramid.tests.test_config.dummy_tween_factory2',
+ 'tests.test_config.dummy_tween_factory2',
over=MAIN,
- under='pyramid.tests.test_config.dummy_tween_factory')
+ under='tests.test_config.dummy_tween_factory')
config.commit()
tweens = config.registry.queryUtility(ITweens)
implicit = tweens.implicit()
@@ -55,9 +55,9 @@ class TestTweensConfiguratorMixin(unittest.TestCase):
implicit,
[
('pyramid.tweens.excview_tween_factory', excview_tween_factory),
- ('pyramid.tests.test_config.dummy_tween_factory',
+ ('tests.test_config.dummy_tween_factory',
dummy_tween_factory),
- ('pyramid.tests.test_config.dummy_tween_factory2',
+ ('tests.test_config.dummy_tween_factory2',
dummy_tween_factory2),
])
@@ -66,7 +66,7 @@ class TestTweensConfiguratorMixin(unittest.TestCase):
config = self._makeOne()
self.assertRaises(
ConfigurationError, config.add_tween,
- 'pyramid.tests.test_config.dummy_tween_factory',
+ 'tests.test_config.dummy_tween_factory',
under=False)
def test_add_tweens_names_with_over_nonstringoriter(self):
@@ -74,20 +74,20 @@ class TestTweensConfiguratorMixin(unittest.TestCase):
config = self._makeOne()
self.assertRaises(
ConfigurationError, config.add_tween,
- 'pyramid.tests.test_config.dummy_tween_factory',
+ 'tests.test_config.dummy_tween_factory',
over=False)
def test_add_tween_dottedname(self):
from pyramid.interfaces import ITweens
from pyramid.tweens import excview_tween_factory
config = self._makeOne()
- config.add_tween('pyramid.tests.test_config.dummy_tween_factory')
+ config.add_tween('tests.test_config.dummy_tween_factory')
config.commit()
tweens = config.registry.queryUtility(ITweens)
self.assertEqual(
tweens.implicit(),
[
- ('pyramid.tests.test_config.dummy_tween_factory',
+ ('tests.test_config.dummy_tween_factory',
dummy_tween_factory),
('pyramid.tweens.excview_tween_factory',
excview_tween_factory),
@@ -102,10 +102,10 @@ class TestTweensConfiguratorMixin(unittest.TestCase):
def test_add_tween_unsuitable(self):
from pyramid.exceptions import ConfigurationError
- import pyramid.tests.test_config
+ import tests.test_config
config = self._makeOne()
self.assertRaises(ConfigurationError, config.add_tween,
- pyramid.tests.test_config)
+ tests.test_config)
def test_add_tween_name_ingress(self):
from pyramid.exceptions import ConfigurationError
@@ -121,8 +121,8 @@ class TestTweensConfiguratorMixin(unittest.TestCase):
def test_add_tweens_conflict(self):
config = self._makeOne()
- config.add_tween('pyramid.tests.test_config.dummy_tween_factory')
- config.add_tween('pyramid.tests.test_config.dummy_tween_factory')
+ config.add_tween('tests.test_config.dummy_tween_factory')
+ config.add_tween('tests.test_config.dummy_tween_factory')
self.assertRaises(ConfigurationConflictError, config.commit)
def test_add_tween_over_ingress(self):
@@ -132,7 +132,7 @@ class TestTweensConfiguratorMixin(unittest.TestCase):
self.assertRaises(
ConfigurationError,
config.add_tween,
- 'pyramid.tests.test_config.dummy_tween_factory',
+ 'tests.test_config.dummy_tween_factory',
over=INGRESS)
def test_add_tween_over_ingress_iterable(self):
@@ -142,7 +142,7 @@ class TestTweensConfiguratorMixin(unittest.TestCase):
self.assertRaises(
ConfigurationError,
config.add_tween,
- 'pyramid.tests.test_config.dummy_tween_factory',
+ 'tests.test_config.dummy_tween_factory',
over=('a', INGRESS))
def test_add_tween_under_main(self):
@@ -152,7 +152,7 @@ class TestTweensConfiguratorMixin(unittest.TestCase):
self.assertRaises(
ConfigurationError,
config.add_tween,
- 'pyramid.tests.test_config.dummy_tween_factory',
+ 'tests.test_config.dummy_tween_factory',
under=MAIN)
def test_add_tween_under_main_iterable(self):
@@ -162,7 +162,7 @@ class TestTweensConfiguratorMixin(unittest.TestCase):
self.assertRaises(
ConfigurationError,
config.add_tween,
- 'pyramid.tests.test_config.dummy_tween_factory',
+ 'tests.test_config.dummy_tween_factory',
under=('a', MAIN))
class TestTweens(unittest.TestCase):
diff --git a/tests/test_config/test_views.py b/tests/test_config/test_views.py
index 6565a35d5..1af3f66bc 100644
--- a/tests/test_config/test_views.py
+++ b/tests/test_config/test_views.py
@@ -2,9 +2,9 @@ import os
import unittest
from pyramid import testing
-from pyramid.tests.test_config import IDummy
+from . import IDummy
-from pyramid.tests.test_config import dummy_view
+from . import dummy_view
from pyramid.compat import (
im_func,
@@ -155,7 +155,7 @@ class TestViewsConfigurationMixin(unittest.TestCase):
def test_add_view_view_callable_dottedname(self):
from pyramid.renderers import null_renderer
config = self._makeOne(autocommit=True)
- config.add_view(view='pyramid.tests.test_config.dummy_view',
+ config.add_view(view='tests.test_config.dummy_view',
renderer=null_renderer)
wrapper = self._getViewCallable(config)
self.assertEqual(wrapper(None, None), 'OK')
@@ -367,7 +367,7 @@ class TestViewsConfigurationMixin(unittest.TestCase):
from pyramid.renderers import null_renderer
view = lambda *arg: 'OK'
config = self._makeOne(autocommit=True)
- config.add_view(context='pyramid.tests.test_config.IDummy',
+ config.add_view(context='tests.test_config.IDummy',
view=view, renderer=null_renderer)
wrapper = self._getViewCallable(config, IDummy)
self.assertEqual(wrapper, view)
@@ -376,7 +376,7 @@ class TestViewsConfigurationMixin(unittest.TestCase):
from pyramid.renderers import null_renderer
view = lambda *arg: 'OK'
config = self._makeOne(autocommit=True)
- config.add_view(for_='pyramid.tests.test_config.IDummy',
+ config.add_view(for_='tests.test_config.IDummy',
view=view, renderer=null_renderer)
wrapper = self._getViewCallable(config, IDummy)
self.assertEqual(wrapper, view)
@@ -1162,7 +1162,7 @@ class TestViewsConfigurationMixin(unittest.TestCase):
)
def test_add_view_with_template_renderer(self):
- from pyramid.tests import test_config
+ from tests import test_config
from pyramid.interfaces import ISettings
class view(object):
def __init__(self, context, request):
@@ -1173,7 +1173,7 @@ class TestViewsConfigurationMixin(unittest.TestCase):
return {'a':'1'}
config = self._makeOne(autocommit=True)
renderer = self._registerRenderer(config)
- fixture = 'pyramid.tests.test_config:files/minimal.txt'
+ fixture = 'tests.test_config:files/minimal.txt'
config.introspection = False
config.add_view(view=view, renderer=fixture)
wrapper = self._getViewCallable(config)
@@ -1210,11 +1210,11 @@ class TestViewsConfigurationMixin(unittest.TestCase):
self.assertEqual(result.body, b'moo')
def test_add_view_with_template_renderer_no_callable(self):
- from pyramid.tests import test_config
+ from tests import test_config
from pyramid.interfaces import ISettings
config = self._makeOne(autocommit=True)
renderer = self._registerRenderer(config)
- fixture = 'pyramid.tests.test_config:files/minimal.txt'
+ fixture = 'tests.test_config:files/minimal.txt'
config.introspection = False
config.add_view(view=None, renderer=fixture)
wrapper = self._getViewCallable(config)
@@ -1522,7 +1522,7 @@ class TestViewsConfigurationMixin(unittest.TestCase):
config = self._makeOne(autocommit=True)
config.add_view(
view=view,
- containment='pyramid.tests.test_config.IDummy',
+ containment='tests.test_config.IDummy',
renderer=null_renderer)
wrapper = self._getViewCallable(config)
context = DummyContext()
@@ -1773,7 +1773,7 @@ class TestViewsConfigurationMixin(unittest.TestCase):
from zope.interface import directlyProvides
class view(object):
__view_defaults__ = {
- 'containment':'pyramid.tests.test_config.IDummy'
+ 'containment':'tests.test_config.IDummy'
}
def __init__(self, request):
pass
@@ -1798,7 +1798,7 @@ class TestViewsConfigurationMixin(unittest.TestCase):
from zope.interface import directlyProvides
config = self._makeOne(autocommit=True)
config.add_view(
- view='pyramid.tests.test_config.test_views.DummyViewDefaultsClass',
+ view='tests.test_config.test_views.DummyViewDefaultsClass',
renderer=null_renderer)
wrapper = self._getViewCallable(config)
context = DummyContext()
@@ -1815,7 +1815,7 @@ class TestViewsConfigurationMixin(unittest.TestCase):
from zope.interface import directlyProvides
config = self._makeOne(autocommit=True)
config.add_view(
- 'pyramid.tests.test_config.test_views.DummyViewDefaultsClass',
+ 'tests.test_config.test_views.DummyViewDefaultsClass',
renderer=null_renderer)
wrapper = self._getViewCallable(config)
context = DummyContext()
@@ -1830,11 +1830,11 @@ class TestViewsConfigurationMixin(unittest.TestCase):
from pyramid.renderers import null_renderer
class view(object):
__view_defaults__ = {
- 'containment':'pyramid.tests.test_config.IDummy'
+ 'containment':'tests.test_config.IDummy'
}
class view2(object):
__view_defaults__ = {
- 'containment':'pyramid.tests.test_config.IFactory'
+ 'containment':'tests.test_config.IFactory'
}
config = self._makeOne(autocommit=False)
config.add_view(
@@ -1849,11 +1849,11 @@ class TestViewsConfigurationMixin(unittest.TestCase):
from pyramid.renderers import null_renderer
class view(object):
__view_defaults__ = {
- 'containment':'pyramid.tests.test_config.IDummy'
+ 'containment':'tests.test_config.IDummy'
}
class view2(object):
__view_defaults__ = {
- 'containment':'pyramid.tests.test_config.IDummy'
+ 'containment':'tests.test_config.IDummy'
}
config = self._makeOne(autocommit=False)
config.add_view(
@@ -1975,7 +1975,7 @@ class TestViewsConfigurationMixin(unittest.TestCase):
from zope.interface import implementedBy
class view(object):
__view_defaults__ = {
- 'containment': 'pyramid.tests.test_config.IDummy'
+ 'containment': 'tests.test_config.IDummy'
}
def __init__(self, request):
pass
@@ -2009,7 +2009,7 @@ class TestViewsConfigurationMixin(unittest.TestCase):
from pyramid.renderers import null_renderer
config = self._makeOne()
result = config.derive_view(
- 'pyramid.tests.test_config.dummy_view',
+ 'tests.test_config.dummy_view',
renderer=null_renderer)
self.assertFalse(result is dummy_view)
self.assertEqual(result(None, None), 'OK')
@@ -2071,10 +2071,10 @@ class TestViewsConfigurationMixin(unittest.TestCase):
config = self._makeOne(autocommit=True)
config.registry.registerUtility(info, IStaticURLInfo)
config.add_static_view('static',
- 'pyramid.tests.test_config:files')
+ 'tests.test_config:files')
self.assertEqual(
info.added,
- [(config, 'static', 'pyramid.tests.test_config:files', {})])
+ [(config, 'static', 'tests.test_config:files', {})])
def test_add_static_view_package_here_relative(self):
from pyramid.interfaces import IStaticURLInfo
@@ -2084,7 +2084,7 @@ class TestViewsConfigurationMixin(unittest.TestCase):
config.add_static_view('static', 'files')
self.assertEqual(
info.added,
- [(config, 'static', 'pyramid.tests.test_config:files', {})])
+ [(config, 'static', 'tests.test_config:files', {})])
def test_add_static_view_absolute(self):
import os
@@ -2169,7 +2169,7 @@ class TestViewsConfigurationMixin(unittest.TestCase):
from zope.interface import implementedBy
class view(object):
__view_defaults__ = {
- 'containment':'pyramid.tests.test_config.IDummy'
+ 'containment':'tests.test_config.IDummy'
}
def __init__(self, request):
pass
@@ -2305,7 +2305,7 @@ class TestViewsConfigurationMixin(unittest.TestCase):
from zope.interface import implementedBy
class view(object):
__view_defaults__ = {
- 'containment':'pyramid.tests.test_config.IDummy'
+ 'containment':'tests.test_config.IDummy'
}
def __init__(self, request):
pass
@@ -2379,9 +2379,9 @@ class TestViewsConfigurationMixin(unittest.TestCase):
def test_set_view_mapper_dottedname(self):
from pyramid.interfaces import IViewMapperFactory
config = self._makeOne(autocommit=True)
- config.set_view_mapper('pyramid.tests.test_config')
+ config.set_view_mapper('tests.test_config')
result = config.registry.getUtility(IViewMapperFactory)
- from pyramid.tests import test_config
+ from tests import test_config
self.assertEqual(result, test_config)
def test_add_normal_and_exception_view_intr_derived_callable(self):
@@ -3284,8 +3284,8 @@ class TestStaticURLInfo(unittest.TestCase):
request = testing.DummyRequest()
config.add_static_view('static', 'path')
config.override_asset(
- 'pyramid.tests.test_config:path/',
- 'pyramid.tests.test_config:other_path/')
+ 'tests.test_config:path/',
+ 'tests.test_config:other_path/')
def cb(val):
def cb_(request, subpath, kw):
kw['_query'] = {'x': val}
@@ -3468,7 +3468,7 @@ class Test_view_description(unittest.TestCase):
def view(): pass
result = self._callFUT(view)
self.assertEqual(result,
- 'function pyramid.tests.test_config.test_views.view')
+ 'function tests.test_config.test_views.view')
class Test_viewdefaults(unittest.TestCase):
def _makeOne(self, wrapped):
@@ -3599,7 +3599,7 @@ class DummyStaticURLInfo:
class DummyViewDefaultsClass(object):
__view_defaults__ = {
- 'containment':'pyramid.tests.test_config.IDummy'
+ 'containment':'tests.test_config.IDummy'
}
def __init__(self, request):
pass