Skip to content

Commit

Permalink
feat(checks) Check for ZopeTestCase tests
Browse files Browse the repository at this point in the history
If there are ZopeTestCase tests, do not run your own tests.
Throw an exception instead
  • Loading branch information
do3cc committed Feb 18, 2016
1 parent b4e128a commit 3268cda
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Changelog

New:

- *add item here*
- Check that tests don't run together with ZopeTestCase
[do3cc]

Fixes:

Expand Down
15 changes: 15 additions & 0 deletions src/plone/testing/z2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from Zope2.App.schema import Zope2VocabularyRegistry
import contextlib
import os
import pkg_resources

try:
from plone.testing._z2_testbrowser import Browser
Expand All @@ -22,6 +23,12 @@
except ImportError:
HAS_ZOPE213 = False

try:
pkg_resources.get_distribution('Zope2')
HAS_ZOPETESTCASE = True
except pkg_resources.DistributionNotFound:
HAS_ZOPETESTCASE = False

_INSTALLED_PRODUCTS = {}


Expand Down Expand Up @@ -544,6 +551,14 @@ def setUpDatabase(self):
the resource stack.
"""

if HAS_ZOPETESTCASE:
from Testing.ZopeTestCase.ZopeLite import _patched as ZOPETESTCASEALERT
if HAS_ZOPETESTCASE and ZOPETESTCASEALERT:
raise Exception('You try to run plone.testing tests together with '
'ZopeTestCase tests. This will result in random '
'failures. Convert the ZopeTestCase Tests or '
'do not run them together')

import Zope2.Startup.datatypes
import App.config

Expand Down

0 comments on commit 3268cda

Please sign in to comment.