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_a_file_named_filename_and_encoding_with(context, filename, encoding): """Creates a textual file with the content provided as docstring.""" __encoding_is_valid = True assert context.text is not None, "ENSURE: multiline text is provided." assert not os.path.isabs(filename) assert __encoding_is_valid command_util.ensure_workdir_exists(context) filename2 = os.path.join(context.workdir, filename) pathutil.create_textfile_with_contents(filename2, context.text, encoding)
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_a_file_named_filename_and_encoding_with(context, filename, encoding): """Creates a textual file with the content provided as docstring.""" __encoding_is_valid = True text_to_use = context.text # TODO refactor this try/except try: if context.surrogate_text is not None: text_to_use = context.surrogate_text else: assert context.text is not None, "ENSURE: multiline text is provided." except AttributeError: assert context.text is not None, "ENSURE: multiline text is provided." assert not os.path.isabs(filename) assert __encoding_is_valid command_util.ensure_workdir_exists(context) filename2 = os.path.join(context.workdir, filename) pathutil.create_textfile_with_contents(filename2, text_to_use, encoding)