def run_features(self, *features, **kwargs): """ Run the specified features. """ # named keyword args and variable positional args aren't supported on # Python 2 verbosity = kwargs.get('verbosity') stream = kwargs.get('stream') force_color = kwargs.get('force_color', False) if stream is None and isinstance(sys.stdout, CAPTURED_OUTPUTS): # Don't show results of running the inner tests if the outer Nose # redirects output stream = str_io() CALLBACK_REGISTRY.clear(priority_class=PriorityClass.USER) STEP_REGISTRY.clear() world.__dict__.clear() argv = ['aloe'] if verbosity: argv += ['--verbosity', str(verbosity)] if force_color: argv += ['--color'] argv += list(features) return TestRunner(exit=False, argv=argv, stream=stream)
def run_features(self, *args, **kwargs): """ Run the specified features. """ # named keyword args and variable positional args aren't supported on # Python 2 verbosity = kwargs.get('verbosity') stream = kwargs.get('stream') force_color = kwargs.get('force_color', False) if stream is None: # redirects output stream = StreamTestWrapperIO() # Reset the state of callbacks and steps so that individual tests don't # affect each other CALLBACK_REGISTRY.clear(priority_class=PriorityClass.USER) STEP_REGISTRY.clear() world.__dict__.clear() old_stdout = sys.stdout sys.stdout = stream result = self.testdir.inline_run(*args, plugins=["pytest_eucalyptus"]) sys.stdout = old_stdout return TestResult(result, stream);
def run_features(self, *features, **kwargs): """ Run the specified features. """ # named keyword args and variable positional args aren't supported on # Python 2 verbosity = kwargs.get('verbosity') stream = kwargs.get('stream') force_color = kwargs.get('force_color', False) if stream is None and isinstance(sys.stdout, CAPTURED_OUTPUTS): # Don't show results of running the inner tests if the outer Nose # redirects output stream = TestWrapperIO() # Reset the state of callbacks and steps so that individual tests don't # affect each other CALLBACK_REGISTRY.clear(priority_class=PriorityClass.USER) STEP_REGISTRY.clear() world.__dict__.clear() argv = ['aloe'] if verbosity: argv += ['--verbosity', str(verbosity)] if force_color: argv += ['--color'] argv += list(features) # Save the loaded module list to restore later old_modules = set(sys.modules.keys()) result = TestRunner(exit=False, argv=argv, stream=stream) result.captured_stream = stream # To avoid affecting the (outer) testsuite and its subsequent tests, # unload all modules that were newly loaded. This also ensures that they # are loaded again for the next tests, registering relevant steps and # hooks. new_modules = set(sys.modules.keys()) for module_name in new_modules - old_modules: del sys.modules[module_name] return result
def prepare_step(cls, step): """ Find a definition for the step. Returns a dictionary of: step, func, args, kwargs, where: - step is the original step - func is the function to run (wrapped in callbacks) - args and kwargs are the arguments to pass to the function """ func, args, kwargs = STEP_REGISTRY.match_step(step) func = CALLBACK_REGISTRY.wrap('step', func, step) return { 'step': step, 'func': func, 'args': args, 'kwargs': kwargs, }
from aloe_webdriver.webdriver import contains_content from nose.tools import assert_true, assert_equal from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.alert import Alert from . import utils from collections import OrderedDict import time logger = logging.getLogger(__name__) # Clearing all the aloe step definitions before we register our own. STEP_REGISTRY.clear() @step('I try to log in') def try_to_login(step): world.browser.get(world.site_url + "login?next=/router/") @step('I should be logged in as an Angelman user called "([^"]+)"') def login_as_angelman_user(step, user_name): world.expected_login_message = "Welcome {0} to the Angelman Registry".format(user_name) @step('I should be at the welcome page and see a message which says "([^"]+)"') def angelman_user_logged_in(step, welcome_message): login_message = world.browser.find_element_by_tag_name('h4').text