def step_a_new_working_directory(context): """ Creates a new, empty working directory """ command_util.ensure_context_attribute_exists(context, "workdir", None) command_util.ensure_workdir_exists(context) shutil.rmtree(context.workdir, ignore_errors=True)
def step_an_empty_file_named_filename(context, filename): """ Creates an empty file. """ assert not os.path.isabs(filename) command_util.ensure_workdir_exists(context) filename2 = os.path.join(context.workdir, filename) command_util.create_textfile_with_contents(filename2, "")
def step_a_directory_without_standard_directory_structure(context): # Given /^a directory without standard Cucumber project directory structure$/ do # in_current_dir do # FileUtils.rm_rf 'features' if File.directory?('features') # end # end command_util.ensure_workdir_exists(context) shutil.rmtree(context.workdir, ignore_errors=True)
def step_an_empty_file_named_filename(context, filename): """ Creates an empty file. """ assert not os.path.isabs(filename) command_util.ensure_workdir_exists(context) filename2 = os.path.join(context.workdir, filename) pathutil.create_textfile_with_contents(filename2, "")
def step_I_run_the_feature_with_the_formatter(context, formatter): # When /^I run the feature with the (\w+) formatter$/ do |formatter| # features.length.should == 1 # run_feature features.first, formatter # end command_util.ensure_workdir_exists(context) command_util.ensure_context_resource_exists(context, "features", []) command = "behave --format={0} {1}".format(formatter, context.features[0]) context.command_result = command_shell.run(command, cwd=context.workdir)
def step_i_run_command(context, command): """ Run a command as subprocess, collect its output and returncode. """ command_util.ensure_workdir_exists(context) context.command_result = command_shell.run(command, cwd=context.workdir) if False and DEBUG: print("XXX run_command: {0}".format(command)) print("XXX run_command.outout {0}".format(context.command_result.output))
def step_i_run_command(context, command): """ Run a command as subprocess, collect its output and returncode. """ command_util.ensure_workdir_exists(context) context.command_result = command_shell.run(command, cwd=context.workdir) command_util.workdir_save_coverage_files(context.workdir) if False and DEBUG: print(u"run_command: {0}".format(command)) print(u"run_command.output {0}".format(context.command_result.output))
def step_a_scenario_with_a_step_that_looks_like_this(context): # Given /^a scenario with a step that looks like this:$/ do |string| # create_feature do # create_scenario { string } # end # end command_util.ensure_workdir_exists(context) scenario_text = context.text filename = behave_builder.create_scenario(scenario_text, cwd=context.workdir) command_util.ensure_context_resource_exists(context, "features", []) context.features.append(filename)
def step_a_file_named_filename_with(context, filename): """ Creates a textual file with the content provided as docstring. """ assert context.text is not None, "ENSURE: multiline text is provided." assert not os.path.isabs(filename) command_util.ensure_workdir_exists(context) filename2 = os.path.join(context.workdir, filename) command_util.create_textfile_with_contents(filename2, context.text) # -- SPECIAL CASE: For usage with behave steps. if filename.endswith(".feature"): command_util.ensure_context_attribute_exists(context, "features", []) context.features.append(filename)
def step_a_file_named_filename_with(context, filename): """ Creates a textual file with the content provided as docstring. """ assert context.text is not None, "ENSURE: multiline text is provided." assert not os.path.isabs(filename) command_util.ensure_workdir_exists(context) filename2 = os.path.join(context.workdir, filename) pathutil.create_textfile_with_contents(filename2, context.text) # -- SPECIAL CASE: For usage with behave steps. if filename.endswith(".feature"): command_util.ensure_context_attribute_exists(context, "features", []) context.features.append(filename)
def step_use_curdir_as_working_directory(context): """ Uses the current directory as working directory """ context.workdir = os.path.abspath(".") command_util.ensure_workdir_exists(context)
def step_a_step_definition_that_looks_like_this(context): # Given /^a step definition that looks like this:$/ do |string| # create_step_definition { string } # end command_util.ensure_workdir_exists(context) behave_builder.create_step_definition(context.text, cwd=context.workdir)
def step_file_named_filename_should_not_exist(context, filename): command_util.ensure_workdir_exists(context) filename_ = pathutil.realpath_with_context(filename, context) assert_that(not os.path.exists(filename_))