summaryrefslogtreecommitdiff
path: root/tests/test_config/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_config/pkgs')
-rw-r--r--tests/test_config/pkgs/__init__.py1
-rw-r--r--tests/test_config/pkgs/asset/__init__.py1
-rw-r--r--tests/test_config/pkgs/asset/subpackage/__init__.py1
-rw-r--r--tests/test_config/pkgs/asset/subpackage/templates/bar.pt0
-rw-r--r--tests/test_config/pkgs/scanextrakw/__init__.py17
-rw-r--r--tests/test_config/pkgs/scannable/__init__.py117
-rw-r--r--tests/test_config/pkgs/scannable/another.py83
-rw-r--r--tests/test_config/pkgs/scannable/pod/notinit.py7
-rw-r--r--tests/test_config/pkgs/scannable/subpackage/__init__.py7
-rw-r--r--tests/test_config/pkgs/scannable/subpackage/notinit.py7
-rw-r--r--tests/test_config/pkgs/scannable/subpackage/subsubpackage/__init__.py7
-rw-r--r--tests/test_config/pkgs/selfscan/__init__.py14
-rw-r--r--tests/test_config/pkgs/selfscan/another.py6
13 files changed, 268 insertions, 0 deletions
diff --git a/tests/test_config/pkgs/__init__.py b/tests/test_config/pkgs/__init__.py
new file mode 100644
index 000000000..5bb534f79
--- /dev/null
+++ b/tests/test_config/pkgs/__init__.py
@@ -0,0 +1 @@
+# package
diff --git a/tests/test_config/pkgs/asset/__init__.py b/tests/test_config/pkgs/asset/__init__.py
new file mode 100644
index 000000000..5bb534f79
--- /dev/null
+++ b/tests/test_config/pkgs/asset/__init__.py
@@ -0,0 +1 @@
+# package
diff --git a/tests/test_config/pkgs/asset/subpackage/__init__.py b/tests/test_config/pkgs/asset/subpackage/__init__.py
new file mode 100644
index 000000000..5bb534f79
--- /dev/null
+++ b/tests/test_config/pkgs/asset/subpackage/__init__.py
@@ -0,0 +1 @@
+# package
diff --git a/tests/test_config/pkgs/asset/subpackage/templates/bar.pt b/tests/test_config/pkgs/asset/subpackage/templates/bar.pt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/test_config/pkgs/asset/subpackage/templates/bar.pt
diff --git a/tests/test_config/pkgs/scanextrakw/__init__.py b/tests/test_config/pkgs/scanextrakw/__init__.py
new file mode 100644
index 000000000..ddda504e1
--- /dev/null
+++ b/tests/test_config/pkgs/scanextrakw/__init__.py
@@ -0,0 +1,17 @@
+import venusian
+
+
+def foo(wrapped):
+ def bar(scanner, name, wrapped):
+ scanner.config.a = scanner.a
+
+ venusian.attach(wrapped, bar)
+ return wrapped
+
+
+@foo
+def hello():
+ pass
+
+
+hello() # appease coverage
diff --git a/tests/test_config/pkgs/scannable/__init__.py b/tests/test_config/pkgs/scannable/__init__.py
new file mode 100644
index 000000000..585f4357b
--- /dev/null
+++ b/tests/test_config/pkgs/scannable/__init__.py
@@ -0,0 +1,117 @@
+from pyramid.view import view_config
+from pyramid.renderers import null_renderer
+
+
+@view_config(renderer=null_renderer)
+def grokked(context, request):
+ return 'grokked'
+
+
+@view_config(request_method='POST', renderer=null_renderer)
+def grokked_post(context, request):
+ return 'grokked_post'
+
+
+@view_config(name='stacked2', renderer=null_renderer)
+@view_config(name='stacked1', renderer=null_renderer)
+def stacked(context, request):
+ return 'stacked'
+
+
+class stacked_class(object):
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+ def __call__(self):
+ return 'stacked_class'
+
+
+stacked_class = view_config(name='stacked_class1', renderer=null_renderer)(
+ stacked_class
+)
+stacked_class = view_config(name='stacked_class2', renderer=null_renderer)(
+ stacked_class
+)
+
+
+class oldstyle_grokked_class:
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+ def __call__(self):
+ return 'oldstyle_grokked_class'
+
+
+oldstyle_grokked_class = view_config(
+ name='oldstyle_grokked_class', renderer=null_renderer
+)(oldstyle_grokked_class)
+
+
+class grokked_class(object):
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+ def __call__(self):
+ return 'grokked_class'
+
+
+grokked_class = view_config(name='grokked_class', renderer=null_renderer)(
+ grokked_class
+)
+
+
+class Foo(object):
+ def __call__(self, context, request):
+ return 'grokked_instance'
+
+
+grokked_instance = Foo()
+grokked_instance = view_config(
+ name='grokked_instance', renderer=null_renderer
+)(grokked_instance)
+
+
+class Base(object):
+ @view_config(name='basemethod', renderer=null_renderer)
+ def basemethod(self):
+ """ """
+
+
+class MethodViews(Base):
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+ @view_config(name='method1', renderer=null_renderer)
+ def method1(self):
+ return 'method1'
+
+ @view_config(name='method2', renderer=null_renderer)
+ def method2(self):
+ return 'method2'
+
+ @view_config(name='stacked_method2', renderer=null_renderer)
+ @view_config(name='stacked_method1', renderer=null_renderer)
+ def stacked(self):
+ return 'stacked_method'
+
+
+# ungrokkable
+
+A = 1
+B = {}
+
+
+def stuff():
+ """ """
+
+
+class Whatever(object):
+ pass
+
+
+class Whatever2:
+ pass
diff --git a/tests/test_config/pkgs/scannable/another.py b/tests/test_config/pkgs/scannable/another.py
new file mode 100644
index 000000000..e8b71e5e3
--- /dev/null
+++ b/tests/test_config/pkgs/scannable/another.py
@@ -0,0 +1,83 @@
+from pyramid.view import view_config
+from pyramid.renderers import null_renderer
+
+
+@view_config(name='another', renderer=null_renderer)
+def grokked(context, request):
+ return 'another_grokked'
+
+
+@view_config(request_method='POST', name='another', renderer=null_renderer)
+def grokked_post(context, request):
+ return 'another_grokked_post'
+
+
+@view_config(name='another_stacked2', renderer=null_renderer)
+@view_config(name='another_stacked1', renderer=null_renderer)
+def stacked(context, request):
+ return 'another_stacked'
+
+
+class stacked_class(object):
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+ def __call__(self):
+ return 'another_stacked_class'
+
+
+stacked_class = view_config(
+ name='another_stacked_class1', renderer=null_renderer
+)(stacked_class)
+stacked_class = view_config(
+ name='another_stacked_class2', renderer=null_renderer
+)(stacked_class)
+
+
+class oldstyle_grokked_class:
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+ def __call__(self):
+ return 'another_oldstyle_grokked_class'
+
+
+oldstyle_grokked_class = view_config(
+ name='another_oldstyle_grokked_class', renderer=null_renderer
+)(oldstyle_grokked_class)
+
+
+class grokked_class(object):
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+ def __call__(self):
+ return 'another_grokked_class'
+
+
+grokked_class = view_config(
+ name='another_grokked_class', renderer=null_renderer
+)(grokked_class)
+
+
+class Foo(object):
+ def __call__(self, context, request):
+ return 'another_grokked_instance'
+
+
+grokked_instance = Foo()
+grokked_instance = view_config(
+ name='another_grokked_instance', renderer=null_renderer
+)(grokked_instance)
+
+# ungrokkable
+
+A = 1
+B = {}
+
+
+def stuff():
+ """ """
diff --git a/tests/test_config/pkgs/scannable/pod/notinit.py b/tests/test_config/pkgs/scannable/pod/notinit.py
new file mode 100644
index 000000000..03c93857f
--- /dev/null
+++ b/tests/test_config/pkgs/scannable/pod/notinit.py
@@ -0,0 +1,7 @@
+from pyramid.view import view_config
+from pyramid.renderers import null_renderer
+
+
+@view_config(name='pod_notinit', renderer=null_renderer)
+def subpackage_notinit(context, request):
+ return 'pod_notinit'
diff --git a/tests/test_config/pkgs/scannable/subpackage/__init__.py b/tests/test_config/pkgs/scannable/subpackage/__init__.py
new file mode 100644
index 000000000..f89ca33f7
--- /dev/null
+++ b/tests/test_config/pkgs/scannable/subpackage/__init__.py
@@ -0,0 +1,7 @@
+from pyramid.view import view_config
+from pyramid.renderers import null_renderer
+
+
+@view_config(name='subpackage_init', renderer=null_renderer)
+def subpackage_init(context, request):
+ return 'subpackage_init'
diff --git a/tests/test_config/pkgs/scannable/subpackage/notinit.py b/tests/test_config/pkgs/scannable/subpackage/notinit.py
new file mode 100644
index 000000000..65c2a4929
--- /dev/null
+++ b/tests/test_config/pkgs/scannable/subpackage/notinit.py
@@ -0,0 +1,7 @@
+from pyramid.view import view_config
+from pyramid.renderers import null_renderer
+
+
+@view_config(name='subpackage_notinit', renderer=null_renderer)
+def subpackage_notinit(context, request):
+ return 'subpackage_notinit'
diff --git a/tests/test_config/pkgs/scannable/subpackage/subsubpackage/__init__.py b/tests/test_config/pkgs/scannable/subpackage/subsubpackage/__init__.py
new file mode 100644
index 000000000..ec4bab818
--- /dev/null
+++ b/tests/test_config/pkgs/scannable/subpackage/subsubpackage/__init__.py
@@ -0,0 +1,7 @@
+from pyramid.view import view_config
+from pyramid.renderers import null_renderer
+
+
+@view_config(name='subsubpackage_init', renderer=null_renderer)
+def subpackage_init(context, request):
+ return 'subsubpackage_init'
diff --git a/tests/test_config/pkgs/selfscan/__init__.py b/tests/test_config/pkgs/selfscan/__init__.py
new file mode 100644
index 000000000..8bc8761ca
--- /dev/null
+++ b/tests/test_config/pkgs/selfscan/__init__.py
@@ -0,0 +1,14 @@
+from pyramid.view import view_config
+
+
+@view_config(renderer='string')
+def abc(request):
+ return 'root'
+
+
+def main():
+ from pyramid.config import Configurator
+
+ c = Configurator()
+ c.scan()
+ return c
diff --git a/tests/test_config/pkgs/selfscan/another.py b/tests/test_config/pkgs/selfscan/another.py
new file mode 100644
index 000000000..79e0b08de
--- /dev/null
+++ b/tests/test_config/pkgs/selfscan/another.py
@@ -0,0 +1,6 @@
+from pyramid.view import view_config
+
+
+@view_config(name='two', renderer='string')
+def two(request):
+ return 'two'