Commits

petraszd committed 686aa34

Init of project

Comments (0)

Files changed (5)

+The MIT License
+
+Copyright (c) 2011 Petras Zdanavičius (petraszd@gmail.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+setup.py
+pytest_gae.py
+README.rst
+LICENSE
+pytest_gae
+==========
+
+TODO
+"""
+TODO
+"""
+import sys
+import os
+import logging
+
+
+def pytest_addoption(parser):
+    group = parser.getgroup("gae", "google app engine plugin")
+    group.addoption('--gae-dir', action='store', dest='gae_dir',
+                    metavar='path', default=None,
+                    help="Google App Engine's source dir")
+    group.addoption('--gae-project-dir', action='store', dest='gae_prj_dir',
+                    metavar='path', default=None,
+                    help="Your app's source code's dir")
+
+
+def pytest_configure(config):
+    gae_path = config.option.gae_dir
+    project_path = config.option.gae_prj_dir
+    if not gae_path or not project_path:
+        return
+
+    sys.path.append(gae_path)
+    sys.path.append(os.path.join(gae_path, 'google'))
+    sys.path.append(os.path.join(gae_path, 'lib/antlr3'))
+    sys.path.append(os.path.join(gae_path, 'lib/django'))
+    sys.path.append(os.path.join(gae_path, 'lib/fancy_urllib'))
+    sys.path.append(os.path.join(gae_path, 'lib/graphy'))
+    sys.path.append(os.path.join(gae_path, 'lib/ipaddr'))
+    sys.path.append(os.path.join(gae_path, 'lib/simplejson'))
+    sys.path.append(os.path.join(gae_path, 'lib/webob'))
+    sys.path.append(os.path.join(gae_path, 'lib/yaml/lib'))
+
+    sys.path.append(project_path)
+
+
+def pytest_runtest_setup(item):
+    gae_path = item.config.option.gae_dir
+    project_path = item.config.option.gae_prj_dir
+
+    if not gae_path or not project_path:
+        return
+
+    from google.appengine.tools import dev_appserver
+    from google.appengine.tools.dev_appserver_main import DEFAULT_ARGS
+
+    config = DEFAULT_ARGS.copy()
+    config.update({'template_dir': os.path.join(gae_path, 'templates'),
+                   'blobstore_path': '/tmp/dev_appserver.test_blobstore',
+                   'root_path': project_path,
+                   'history_path': '/tmp/dev_appserver.datastore.test_history',
+                   'datastore_path': '/tmp/dev_appserver.test_datastore',
+                   'matcher_path': '/tmp/dev_appserver.test_matcher',
+                   'clear_datastore': True})
+
+    app_cfg, _junk = dev_appserver.LoadAppConfig(project_path, {})
+    dev_appserver.SetupStubs(app_cfg.application, **config)
+
+
+def pytest_runtest_teardown(item):
+    # There is some problems with GAE and
+    # py.test miscomunication that causes
+    # closed stream handler to be flushed.
+    #
+    # Wich of course causes Exception and
+    # some nasty errors at the end of passes tests
+    for h in logging.getLogger().handlers:
+        if isinstance(h, logging.StreamHandler):
+            attach_save_flush(h)
+
+
+def attach_save_flush(handler):
+    def save_flush():
+        if not handler.stream.closed:
+            handler.stream.flush()
+
+    handler.flush = save_flush
+from setuptools import setup
+
+
+with open('README.rst', 'r') as f:
+    long_desc = f.read()
+
+setup(name='pytest_gae',
+      version='pre-release',
+      description="py.test plugin for google app engine",
+      long_description=long_desc,
+      author='Petras Zdanavicius (petraszd)',
+      author_email='petras@gmail.com',
+      #url='',
+      py_modules=['pytest_gae'],
+      install_requires=['pytest'],
+      entry_points={'pytest11': ['pytest_gae = pytest_gae']},
+      license='MIT License',
+      keywords='py.test pytest google app engine')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.