Permalink
Browse files

Move splinter dependency to a `splinter` extras.

This is currently necessary since we have to use splinter from source
because of an lxml pinning issue.
  • Loading branch information...
jone committed Mar 26, 2013
1 parent d426e07 commit e79fd6d53b6f814fbd0ed52e63ef775cc4aea10d
Showing with 70 additions and 58 deletions.
  1. +4 −0 README.rst
  2. +12 −3 ftw/testing/__init__.py
  3. +49 −0 ftw/testing/browser.py
  4. +0 −52 ftw/testing/layer.py
  5. +5 −3 setup.py
View
@@ -21,6 +21,10 @@ such as Firefox or Chrome with the same API.
The `ftw.testing` package provides integration of `Splinter`_ with Plone
using Page Objects.
+For using the splinter features, use the `splinter` extras require::
+
+ ftw.testing [splinter]
+
Setting a package up for browser tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
View
@@ -1,7 +1,16 @@
-from ftw.testing.browser import browser
-from ftw.testing.browser import javascript
from ftw.testing.layer import ComponentRegistryLayer
-from ftw.testing.layer import FunctionalSplinterTesting
from ftw.testing.robotfw import LocalizedRobotLayer
from ftw.testing.robotfw import RobotLibrary
from ftw.testing.testcase import MockTestCase
+import pkg_resources
+
+try:
+ pkg_resources.get_distribution('splinter')
+
+except pkg_resources.DistributionNotFound:
+ pass
+
+else:
+ from ftw.testing.browser import FunctionalSplinterTesting
+ from ftw.testing.browser import browser
+ from ftw.testing.browser import javascript
View
@@ -1,4 +1,53 @@
+from plone.app.testing import PLONE_ZSERVER
+from plone.app.testing.layers import FunctionalTesting
+from plone.testing import z2
+from plone.testing._z2_testbrowser import Zope2MechanizeBrowser
from splinter.browser import Browser
+from splinter.browser import _DRIVERS
+from splinter.driver.zopetestbrowser import ZopeTestBrowser
+
+
+class FunctionalSplinterTesting(FunctionalTesting):
+
+ defaultBases = ()
+
+ def __init__(self, bases=None, name=None, module=None):
+ # We need to make sure that we open the ZSERVER port
+ # by using the PLONE_ZSERVER layer.
+ if not bases:
+ bases = self.defaultBases
+ bases = bases + (PLONE_ZSERVER, )
+
+ super(FunctionalSplinterTesting, self).__init__(
+ bases=bases, name=name, module=module)
+
+ def testSetUp(self):
+ super(FunctionalSplinterTesting, self).testSetUp()
+ # The default browser is zope.testbrowser.
+ # The browser may be changed later using decorators.
+ set_browser_driver('zope.testbrowser')
+
+ def testTearDown(self):
+ shutdown_browser()
+ super(FunctionalSplinterTesting, self).testTearDown()
+
+ def tearDown(self):
+ shutdown_all_browser()
+ super(FunctionalSplinterTesting, self).tearDown()
+
+
+class PloneZopeTestBrowser(ZopeTestBrowser):
+
+ def __init__(self, *args, **kwargs):
+ super(PloneZopeTestBrowser, self).__init__(*args, **kwargs)
+ self._browser.handleErrors = False
+
+ def _get_mech_browser(self, user_agent):
+ with z2.zopeApp() as app:
+ return Zope2MechanizeBrowser(app)
+
+
+_DRIVERS['zope.testbrowser'] = PloneZopeTestBrowser
CURRENT_BROWSER_DRIVER = None
View
@@ -1,14 +1,5 @@
-from ftw.testing.browser import set_browser_driver
-from ftw.testing.browser import shutdown_all_browser
-from ftw.testing.browser import shutdown_browser
-from plone.app.testing import PLONE_ZSERVER
-from plone.app.testing.layers import FunctionalTesting
from plone.testing import Layer
-from plone.testing import z2
from plone.testing import zca
-from plone.testing._z2_testbrowser import Zope2MechanizeBrowser
-from splinter.browser import _DRIVERS
-from splinter.driver.zopetestbrowser import ZopeTestBrowser
from zope.configuration import xmlconfig
import zope.component.testing
@@ -54,46 +45,3 @@ def _get_configuration_context(self):
self.get('configurationContext'))
self['configurationContext'] = self._configuration_context
return self._configuration_context
-
-
-class FunctionalSplinterTesting(FunctionalTesting):
-
- defaultBases = ()
-
- def __init__(self, bases=None, name=None, module=None):
- # We need to make sure that we open the ZSERVER port
- # by using the PLONE_ZSERVER layer.
- if not bases:
- bases = self.defaultBases
- bases = bases + (PLONE_ZSERVER, )
-
- super(FunctionalSplinterTesting, self).__init__(
- bases=bases, name=name, module=module)
-
- def testSetUp(self):
- super(FunctionalSplinterTesting, self).testSetUp()
- # The default browser is zope.testbrowser.
- # The browser may be changed later using decorators.
- set_browser_driver('zope.testbrowser')
-
- def testTearDown(self):
- shutdown_browser()
- super(FunctionalSplinterTesting, self).testTearDown()
-
- def tearDown(self):
- shutdown_all_browser()
- super(FunctionalSplinterTesting, self).tearDown()
-
-
-class PloneZopeTestBrowser(ZopeTestBrowser):
-
- def __init__(self, *args, **kwargs):
- super(PloneZopeTestBrowser, self).__init__(*args, **kwargs)
- self._browser.handleErrors = False
-
- def _get_mech_browser(self, user_agent):
- with z2.zopeApp() as app:
- return Zope2MechanizeBrowser(app)
-
-
-_DRIVERS['zope.testbrowser'] = PloneZopeTestBrowser
View
@@ -10,14 +10,17 @@
'robotframework-selenium2library',
'robotsuite',
'decorator',
- 'selenium']}
+ 'selenium'],
+
+ 'splinter': [
+ 'splinter']}
tests_require = [
'Acquisition<4.0a1',
'Products.PloneHotfix20121106',
'Plone',
'plone.app.testing',
- ] + extras_require['robot']
+ ] + extras_require['robot'] + extras_require['splinter']
extras_require['tests'] = tests_require
@@ -58,7 +61,6 @@
'setuptools',
'plone.mocktestcase',
'plone.testing',
- 'splinter',
'unittest2',
'zope.component',
'zope.configuration',

0 comments on commit e79fd6d

Please sign in to comment.