From 2ec37b1d825bc1aecc323f8b7b42a268f838c539 Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Wed, 10 Dec 2008 16:10:48 +0600 Subject: [PATCH] added exit_unless_twisted function to greentest; moved my code from test_support.py to greentest/__init__.py --- greentest/__init__.py | 14 +++++++++++++- greentest/record_results.py | 2 +- greentest/test__twistedutil.py | 8 +++----- greentest/test_support.py | 4 ---- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/greentest/__init__.py b/greentest/__init__.py index f2192ab..2d0f058 100644 --- a/greentest/__init__.py +++ b/greentest/__init__.py @@ -1 +1,13 @@ -# package is named greentest, not test, so it won't be confused with test in stdlib \ No newline at end of file +# package is named greentest, not test, so it won't be confused with test in stdlib +import sys + +disabled_marker = '-*-*-*-*-*- disabled -*-*-*-*-*-' +def exit_disabled(): + sys.exit(disabled_marker) + +def exit_unless_twisted(): + from eventlet.api import get_hub + if 'Twisted' not in type(get_hub()).__name__: + exit_disabled() + + diff --git a/greentest/record_results.py b/greentest/record_results.py index 76c29c6..109bf2a 100755 --- a/greentest/record_results.py +++ b/greentest/record_results.py @@ -7,7 +7,7 @@ import sys import os import sqlite3 import warnings -from greentest.test_support import disabled_marker +from greentest import disabled_marker warnings.simplefilter('ignore') diff --git a/greentest/test__twistedutil.py b/greentest/test__twistedutil.py index 06b70ef..bfd5c9b 100644 --- a/greentest/test__twistedutil.py +++ b/greentest/test__twistedutil.py @@ -1,14 +1,12 @@ +from twisted.internet import reactor +from greentest import exit_unless_twisted +exit_unless_twisted() import sys import unittest from twisted.internet.error import DNSLookupError from twisted.internet import defer from twisted.python.failure import Failure from eventlet.twistedutil import block_on -from eventlet.api import get_hub -from greentest.test_support import exit_disabled - -if 'Twisted' not in type(get_hub()).__name__: - exit_disabled() class Test(unittest.TestCase): diff --git a/greentest/test_support.py b/greentest/test_support.py index 7a0af4d..0b4494c 100644 --- a/greentest/test_support.py +++ b/greentest/test_support.py @@ -5,10 +5,6 @@ if __name__ != 'greentest.test_support': import sys -disabled_marker = '-*-*-*-*-*- disabled -*-*-*-*-*-' -def exit_disabled(): - sys.exit(disabled_marker) - class Error(Exception): """Base class for regression test exceptions."""