diff --git a/requirements.check.txt b/requirements.check.txt index 6a9fe43dc..463b1c51f 100644 --- a/requirements.check.txt +++ b/requirements.check.txt @@ -2,7 +2,7 @@ toml # Lint mypy>=0.910 -ruff +ruff>=0.9 # Unit tests pytest>=6.2.2 diff --git a/ruff.toml b/ruff.toml index 7c4462856..87f58a7ac 100644 --- a/ruff.toml +++ b/ruff.toml @@ -88,8 +88,16 @@ ignore = [ # Avoid trying to fix flake8-bugbear (`B`) violations. unfixable = ["B"] +# Skip non UTF-8 test files +exclude = ["tests/**/invalid_file*"] + # B008 Do not perform function calls in argument defaults. # The call is performed only once at function definition time. [lint.per-file-ignores] "strictdoc/server/routers/main_router.py" = ["B008"] + +# Some of our helpers have deliberatly the name of a standard library module + +[lint.flake8-builtins] +builtins-allowed-modules = ["math", "pickle", "string"] diff --git a/strictdoc/backend/reqif/reqif_import.py b/strictdoc/backend/reqif/reqif_import.py index 2056ac77b..d1c82f29b 100644 --- a/strictdoc/backend/reqif/reqif_import.py +++ b/strictdoc/backend/reqif/reqif_import.py @@ -21,9 +21,9 @@ def import_from_file( ) -> List[SDocDocument]: converter = ReqIFImport.select_reqif_profile(import_config) - assert os.path.isfile( + assert os.path.isfile(import_config.input_path), ( import_config.input_path - ), import_config.input_path + ) if import_config.input_path.endswith(".reqifz"): reqifz_bundle: ReqIFZBundle = ReqIFZParser.parse( diff --git a/strictdoc/backend/sdoc/error_handling.py b/strictdoc/backend/sdoc/error_handling.py index 135ecdda9..f5bede24a 100644 --- a/strictdoc/backend/sdoc/error_handling.py +++ b/strictdoc/backend/sdoc/error_handling.py @@ -128,9 +128,9 @@ def wrong_field_order( problematic_field: SDocNodeField, path_to_sdoc_file: str, ): - assert isinstance( - problematic_field, SDocNodeField - ), f"{problematic_field}" + assert isinstance(problematic_field, SDocNodeField), ( + f"{problematic_field}" + ) requirement_dump = node.dump_fields_as_parsed() grammar_dump = document_grammar.dump_fields(node.node_type) return StrictDocSemanticError( diff --git a/strictdoc/backend/sdoc/models/node.py b/strictdoc/backend/sdoc/models/node.py index b7006f3ff..0de2bf85a 100644 --- a/strictdoc/backend/sdoc/models/node.py +++ b/strictdoc/backend/sdoc/models/node.py @@ -60,9 +60,9 @@ def create_from_string( multiline: bool, ) -> "SDocNodeField": assert isinstance(field_name, str) and len(field_name) > 0, field_name - assert ( - isinstance(field_value, str) and len(field_value) > 0 - ), field_value + assert isinstance(field_value, str) and len(field_value) > 0, ( + field_value + ) return SDocNodeField( parent=parent, @@ -223,9 +223,9 @@ def reserved_tags(self) -> Optional[List[str]]: field: SDocNodeField = self.ordered_fields_lookup[ RequirementFieldName.TAGS ][0] - assert ( - not field.is_multiline() - ), f"Field {RequirementFieldName.TAGS} must be a single-line field." + assert not field.is_multiline(), ( + f"Field {RequirementFieldName.TAGS} must be a single-line field." + ) tags = field.get_text_value().split(", ") return tags @@ -286,9 +286,9 @@ def document(self) -> SDocDocument: document: Optional[SDocDocument] = ( self.ng_document_reference.get_document() ) - assert ( - document is not None - ), "A valid requirement must always have a reference to the document." + assert document is not None, ( + "A valid requirement must always have a reference to the document." + ) return document def get_document(self) -> Optional[SDocDocument]: @@ -325,9 +325,9 @@ def parent_or_including_document(self) -> SDocDocument: document: Optional[SDocDocument] = ( self.ng_document_reference.get_document() ) - assert ( - document is not None - ), "A valid requirement must always have a reference to the document." + assert document is not None, ( + "A valid requirement must always have a reference to the document." + ) return document def document_is_included(self) -> bool: diff --git a/strictdoc/backend/sdoc/models/object_factory.py b/strictdoc/backend/sdoc/models/object_factory.py index d0ed1aa5e..67a00e44c 100644 --- a/strictdoc/backend/sdoc/models/object_factory.py +++ b/strictdoc/backend/sdoc/models/object_factory.py @@ -74,9 +74,9 @@ def create_requirement( ) ) if statement_multiline is not None: - assert isinstance( - statement_multiline, str - ), f"{statement_multiline}" + assert isinstance(statement_multiline, str), ( + f"{statement_multiline}" + ) fields.append( SDocNodeField.create_from_string( parent=None, diff --git a/strictdoc/backend/sdoc/models/section.py b/strictdoc/backend/sdoc/models/section.py index 9b35f2b5b..9f0007d23 100644 --- a/strictdoc/backend/sdoc/models/section.py +++ b/strictdoc/backend/sdoc/models/section.py @@ -110,9 +110,9 @@ def parent_or_including_document(self) -> SDocDocument: document: Optional[SDocDocument] = ( self.ng_document_reference.get_document() ) - assert ( - document is not None - ), "A valid requirement must always have a reference to the document." + assert document is not None, ( + "A valid requirement must always have a reference to the document." + ) return document def document_is_included(self): diff --git a/strictdoc/backend/sdoc/processor.py b/strictdoc/backend/sdoc/processor.py index cc5c7be7e..09fdacc5b 100644 --- a/strictdoc/backend/sdoc/processor.py +++ b/strictdoc/backend/sdoc/processor.py @@ -168,9 +168,9 @@ def process_section(self, section: SDocSection): ) def process_document_from_file(self, document_from_file: DocumentFromFile): - assert isinstance( - document_from_file, DocumentFromFile - ), document_from_file + assert isinstance(document_from_file, DocumentFromFile), ( + document_from_file + ) # Windows paths are backslashes, so using abspath in addition. resolved_path_to_fragment_file = os.path.abspath( diff --git a/strictdoc/backend/sdoc/writer.py b/strictdoc/backend/sdoc/writer.py index a07f05575..fe840ee36 100644 --- a/strictdoc/backend/sdoc/writer.py +++ b/strictdoc/backend/sdoc/writer.py @@ -109,6 +109,11 @@ def write_with_fragments( output += f"VERSION: {version}" output += "\n" + date = document_config.date + if date is not None: + output += f"DATE: {date}" + output += "\n" + classification = document_config.classification if classification is not None: output += f"CLASSIFICATION: {classification}" @@ -256,9 +261,9 @@ def _print_node( document_iterator: DocumentCachingIterator, convert_free_text_to_text: bool = False, ): - assert isinstance( - document_iterator, DocumentCachingIterator - ), document_iterator + assert isinstance(document_iterator, DocumentCachingIterator), ( + document_iterator + ) if isinstance(root_node, SDocDocument): output = "" diff --git a/strictdoc/backend/sdoc_source_code/reader.py b/strictdoc/backend/sdoc_source_code/reader.py index 3e7fb17e6..684a5c819 100644 --- a/strictdoc/backend/sdoc_source_code/reader.py +++ b/strictdoc/backend/sdoc_source_code/reader.py @@ -32,9 +32,9 @@ def __init__(self, lines_total): def req_processor(req: Req): - assert isinstance( - req, Req - ), f"Expected req to be Req, got: {req}, {type(req)}" + assert isinstance(req, Req), ( + f"Expected req to be Req, got: {req}, {type(req)}" + ) location = get_location(req) assert location req.ng_source_line = location["line"] diff --git a/strictdoc/core/actions/export_action.py b/strictdoc/core/actions/export_action.py index 2be4b0711..efb81776d 100644 --- a/strictdoc/core/actions/export_action.py +++ b/strictdoc/core/actions/export_action.py @@ -51,9 +51,9 @@ def build_index(self) -> None: @timing_decorator("Export SDoc") def export(self) -> None: - assert ( - self.traceability_index is not None - ), "The index must be built at this point." + assert self.traceability_index is not None, ( + "The index must be built at this point." + ) if ( "html" in self.project_config.export_formats or "html-standalone" in self.project_config.export_formats diff --git a/strictdoc/core/asset_manager.py b/strictdoc/core/asset_manager.py index 2bec3dbe5..f94457db4 100644 --- a/strictdoc/core/asset_manager.py +++ b/strictdoc/core/asset_manager.py @@ -11,9 +11,9 @@ class AssetDir: relative_path: SDocRelativePath def __post_init__(self): - assert isinstance( - self.relative_path, SDocRelativePath - ), self.relative_path + assert isinstance(self.relative_path, SDocRelativePath), ( + self.relative_path + ) class AssetManager: diff --git a/strictdoc/core/document_finder.py b/strictdoc/core/document_finder.py index a71bbbb0e..8390b7920 100644 --- a/strictdoc/core/document_finder.py +++ b/strictdoc/core/document_finder.py @@ -115,9 +115,9 @@ def _build_document_tree( doc_file: File for doc_file, file_tree_mount_folder, document in found_documents: - assert isinstance( - file_tree_mount_folder, str - ), file_tree_mount_folder + assert isinstance(file_tree_mount_folder, str), ( + file_tree_mount_folder + ) if isinstance(document, DocumentGrammar): map_grammars_by_filenames[doc_file.file_name] = document diff --git a/strictdoc/core/document_meta.py b/strictdoc/core/document_meta.py index 0de84f045..3607cb296 100644 --- a/strictdoc/core/document_meta.py +++ b/strictdoc/core/document_meta.py @@ -38,18 +38,18 @@ def __init__( output_document_dir_rel_path = "doc_project" ) """ - assert isinstance( - input_doc_rel_path, SDocRelativePath - ), input_doc_rel_path - assert isinstance( - input_doc_dir_rel_path, SDocRelativePath - ), input_doc_dir_rel_path - assert isinstance( - input_doc_assets_dir_rel_path, SDocRelativePath - ), input_doc_assets_dir_rel_path - assert isinstance( - output_document_dir_rel_path, SDocRelativePath - ), output_document_dir_rel_path + assert isinstance(input_doc_rel_path, SDocRelativePath), ( + input_doc_rel_path + ) + assert isinstance(input_doc_dir_rel_path, SDocRelativePath), ( + input_doc_dir_rel_path + ) + assert isinstance(input_doc_assets_dir_rel_path, SDocRelativePath), ( + input_doc_assets_dir_rel_path + ) + assert isinstance(output_document_dir_rel_path, SDocRelativePath), ( + output_document_dir_rel_path + ) self.level: int = level self.file_tree_mount_folder = file_tree_mount_folder diff --git a/strictdoc/core/graph/one_to_one_dictionary.py b/strictdoc/core/graph/one_to_one_dictionary.py index 36612b17a..2e8561841 100644 --- a/strictdoc/core/graph/one_to_one_dictionary.py +++ b/strictdoc/core/graph/one_to_one_dictionary.py @@ -34,9 +34,9 @@ def create_link( assert edge is None assert isinstance(lhs_node, self._lhs_type), (lhs_node, self._lhs_type) assert isinstance(rhs_node, self._rhs_type), (rhs_node, self._rhs_type) - assert ( - lhs_node not in self._dict - ), f"OneToOneDictionary: Cannot create a link because lhs_node already exists: {lhs_node}." + assert lhs_node not in self._dict, ( + f"OneToOneDictionary: Cannot create a link because lhs_node already exists: {lhs_node}." + ) self._dict[lhs_node] = rhs_node def create_link_weak(self, *, lhs_node: Any, rhs_node: Any): diff --git a/strictdoc/core/project_config.py b/strictdoc/core/project_config.py index e2905f32b..ae43e347e 100644 --- a/strictdoc/core/project_config.py +++ b/strictdoc/core/project_config.py @@ -586,9 +586,9 @@ def _load_from_dictionary( # FIXME reqif_import_markup = reqif_content.get("import_markup", None) if reqif_import_markup is not None: - assert ( - reqif_import_markup in SDocMarkup.ALL - ), reqif_import_markup + assert reqif_import_markup in SDocMarkup.ALL, ( + reqif_import_markup + ) return ProjectConfig( environment=environment, diff --git a/strictdoc/core/traceability_index_builder.py b/strictdoc/core/traceability_index_builder.py index 721e4672b..ebb93c9aa 100644 --- a/strictdoc/core/traceability_index_builder.py +++ b/strictdoc/core/traceability_index_builder.py @@ -710,9 +710,9 @@ def child_cycle_traverse_(node_id): for document_from_file_ in document_.fragments_from_files: traceability_index.contains_included_documents = True - assert isinstance( - document_from_file_, DocumentFromFile - ), document_from_file_ + assert isinstance(document_from_file_, DocumentFromFile), ( + document_from_file_ + ) assert ( document_from_file_.resolved_full_path_to_document_file diff --git a/strictdoc/export/html/form_objects/form_object.py b/strictdoc/export/html/form_objects/form_object.py index d8391124a..4732eaaa8 100644 --- a/strictdoc/export/html/form_objects/form_object.py +++ b/strictdoc/export/html/form_objects/form_object.py @@ -12,9 +12,9 @@ class RowWithReservedFieldFormObject: jinja_environment: JinjaEnvironment def __post_init__(self): - assert isinstance( - self.jinja_environment, JinjaEnvironment - ), self.jinja_environment + assert isinstance(self.jinja_environment, JinjaEnvironment), ( + self.jinja_environment + ) def render(self): rendered_template = self.jinja_environment.render_template_as_markup( @@ -35,9 +35,9 @@ class RowWithCustomFieldFormObject: def __post_init__(self): assert self.field is not None - assert isinstance( - self.jinja_environment, JinjaEnvironment - ), self.jinja_environment + assert isinstance(self.jinja_environment, JinjaEnvironment), ( + self.jinja_environment + ) def render(self): rendered_template = self.jinja_environment.render_template_as_markup( @@ -58,9 +58,9 @@ class RowWithRelationFormObject: def __post_init__(self): assert self.relation is not None - assert isinstance( - self.jinja_environment, JinjaEnvironment - ), self.jinja_environment + assert isinstance(self.jinja_environment, JinjaEnvironment), ( + self.jinja_environment + ) def render(self): rendered_template = self.jinja_environment.render_template_as_markup( diff --git a/strictdoc/export/html/form_objects/rows/row_with_grammar_element_form_object.py b/strictdoc/export/html/form_objects/rows/row_with_grammar_element_form_object.py index b8143ed9b..b1aefde89 100644 --- a/strictdoc/export/html/form_objects/rows/row_with_grammar_element_form_object.py +++ b/strictdoc/export/html/form_objects/rows/row_with_grammar_element_form_object.py @@ -13,9 +13,9 @@ class RowWithGrammarElementFormObject: def __post_init__(self): assert self.field is not None - assert isinstance( - self.jinja_environment, JinjaEnvironment - ), self.jinja_environment + assert isinstance(self.jinja_environment, JinjaEnvironment), ( + self.jinja_environment + ) def render(self): if self.field.is_new: diff --git a/strictdoc/export/html/generators/source_file_view_generator.py b/strictdoc/export/html/generators/source_file_view_generator.py index 88dd8caa3..5c899e6ec 100644 --- a/strictdoc/export/html/generators/source_file_view_generator.py +++ b/strictdoc/export/html/generators/source_file_view_generator.py @@ -196,9 +196,9 @@ def get_pygmented_source_lines( start_pattern = '
'
         end_pattern = "
\n" assert pygmented_source_file_content.startswith(start_pattern) - assert pygmented_source_file_content.endswith( - end_pattern - ), f"{pygmented_source_file_content}" + assert pygmented_source_file_content.endswith(end_pattern), ( + f"{pygmented_source_file_content}" + ) slice_start = len(start_pattern) slice_end = len(pygmented_source_file_content) - len(end_pattern) @@ -213,9 +213,9 @@ def get_pygmented_source_lines( if pygmented_source_file_lines[-1] == "": pygmented_source_file_lines.pop() - assert ( - "###" in pygmented_source_file_lines[-1] - ), "Expected marker to be in place." + assert "###" in pygmented_source_file_lines[-1], ( + "Expected marker to be in place." + ) # Pop ###, pop "\n" pygmented_source_file_lines.pop() if pygmented_source_file_lines[-1] == "": diff --git a/strictdoc/export/html/renderers/link_renderer.py b/strictdoc/export/html/renderers/link_renderer.py index 544fb8d66..1aa444253 100644 --- a/strictdoc/export/html/renderers/link_renderer.py +++ b/strictdoc/export/html/renderers/link_renderer.py @@ -187,11 +187,7 @@ def render_source_file_link( document: SDocDocument = document_or_none path_prefix = document.meta.get_root_path_prefix() source_file_link = ( - f"{path_prefix}" - "/" - f"_source_files" - "/" - f"{requirement_source_path}.html" + f"{path_prefix}/_source_files/{requirement_source_path}.html" ) return source_file_link diff --git a/strictdoc/export/spdx/spdx_generator.py b/strictdoc/export/spdx/spdx_generator.py index 81c42f5e9..3b4077a9a 100644 --- a/strictdoc/export/spdx/spdx_generator.py +++ b/strictdoc/export/spdx/spdx_generator.py @@ -271,9 +271,9 @@ def export_tree( if node.reserved_uid is None: continue - assert ( - node.reserved_title is not None - ), "The current implementation only supports requirements with a title." + assert node.reserved_title is not None, ( + "The current implementation only supports requirements with a title." + ) """ Create SPDX Snippet from SDoc Requirement. diff --git a/strictdoc/export/spdx/spdx_to_sdoc_converter.py b/strictdoc/export/spdx/spdx_to_sdoc_converter.py index 249a640b5..ba2eff3e1 100644 --- a/strictdoc/export/spdx/spdx_to_sdoc_converter.py +++ b/strictdoc/export/spdx/spdx_to_sdoc_converter.py @@ -135,9 +135,9 @@ def convert(spdx_container: SPDXSDocContainer) -> SDocDocument: ] to_element_sdoc = map_spdxref_to_sdoc[to_element.spdx_id] - assert ( - to_element_sdoc.reserved_uid is not None - ), to_element_sdoc + assert to_element_sdoc.reserved_uid is not None, ( + to_element_sdoc + ) from_element_sdoc.relations.append( ChildReqReference( @@ -162,9 +162,9 @@ def convert(spdx_container: SPDXSDocContainer) -> SDocDocument: ] to_element_sdoc = map_spdxref_to_sdoc[to_element.spdx_id] - assert ( - to_element_sdoc.reserved_uid is not None - ), to_element_sdoc + assert to_element_sdoc.reserved_uid is not None, ( + to_element_sdoc + ) from_element_sdoc.relations.append( ParentReqReference( diff --git a/strictdoc/server/routers/main_router.py b/strictdoc/server/routers/main_router.py index 2921a8628..ca3b35e6e 100644 --- a/strictdoc/server/routers/main_router.py +++ b/strictdoc/server/routers/main_router.py @@ -229,10 +229,7 @@ def requirement__show_full(reference_mid: str): standalone=False, ) output = env().render_template_as_markup( - "actions/" - "node/" - "show_full_node/" - "stream_show_full_requirement.jinja", + "actions/node/show_full_node/stream_show_full_requirement.jinja", view_object=view_object, requirement=requirement, ) @@ -265,10 +262,7 @@ def section__show_full(reference_mid: str): project_config.view ) output = env().render_template_as_markup( - "actions/" - "node/" - "show_full_node/" - "stream_show_full_section.jinja", + "actions/node/show_full_node/stream_show_full_section.jinja", renderer=markup_renderer, section=section, traceability_index=export_action.traceability_index, @@ -293,9 +287,9 @@ def get_new_section( assert isinstance(whereto, str), whereto assert NodeCreationOrder.is_valid(whereto), whereto - assert ( - isinstance(reference_mid, str) and len(reference_mid) > 0 - ), reference_mid + assert isinstance(reference_mid, str) and len(reference_mid) > 0, ( + reference_mid + ) section_form_object = SectionFormObject.create_new( context_document_mid=context_document_mid @@ -521,9 +515,9 @@ async def put_update_section(request: Request): MID(section_mid) ) - assert ( - isinstance(section_mid, str) and len(section_mid) > 0 - ), f"{section_mid}" + assert isinstance(section_mid, str) and len(section_mid) > 0, ( + f"{section_mid}" + ) form_object: SectionFormObject = SectionFormObject.create_from_request( section_mid=section_mid, @@ -1089,9 +1083,9 @@ async def document__update_requirement(request: Request): ) document = requirement.document - assert ( - isinstance(requirement_mid, str) and len(requirement_mid) > 0 - ), f"{requirement_mid}" + assert isinstance(requirement_mid, str) and len(requirement_mid) > 0, ( + f"{requirement_mid}" + ) form_object: RequirementFormObject = ( RequirementFormObject.create_from_request( @@ -1238,9 +1232,9 @@ def cancel_new_requirement(requirement_mid: str): "/actions/document/cancel_edit_requirement", response_class=Response ) def cancel_edit_requirement(requirement_mid: str): - assert ( - isinstance(requirement_mid, str) and len(requirement_mid) > 0 - ), f"{requirement_mid}" + assert isinstance(requirement_mid, str) and len(requirement_mid) > 0, ( + f"{requirement_mid}" + ) requirement: SDocNode = ( export_action.traceability_index.get_node_by_mid( MID(requirement_mid) @@ -2248,10 +2242,7 @@ async def document__save_grammar(request: Request): output = ( form_object.render_close_form() + env().render_template_as_markup( - "actions/" - "document/" - "_shared/" - "stream_refresh_document.jinja.html", + "actions/document/_shared/stream_refresh_document.jinja.html", view_object=view_object, ) ) @@ -2391,10 +2382,7 @@ async def document__save_grammar_element(request: Request): output = ( form_object.render_close_form() + env().render_template_as_markup( - "actions/" - "document/" - "_shared/" - "stream_refresh_document.jinja.html", + "actions/document/_shared/stream_refresh_document.jinja.html", view_object=view_object, ) ) diff --git a/tasks.py b/tasks.py index 943c83b02..8148baf16 100644 --- a/tasks.py +++ b/tasks.py @@ -235,9 +235,9 @@ def test_end2end( ) parallelize_argument = "--numprocesses=2 --strictdoc-parallelize" - assert shard is None or re.match( - r"[1-9][0-9]*/[1-9][0-9]*", shard - ), f"--shard argument has an incorrect format: {shard}." + assert shard is None or re.match(r"[1-9][0-9]*/[1-9][0-9]*", shard), ( + f"--shard argument has an incorrect format: {shard}." + ) shard_argument = f"--strictdoc-shard={shard}" if shard else "" focus_argument = f"-k {focus}" if focus is not None else "" diff --git a/tests/end2end/end2end_test_setup.py b/tests/end2end/end2end_test_setup.py index 41badcb0e..05be19430 100644 --- a/tests/end2end/end2end_test_setup.py +++ b/tests/end2end/end2end_test_setup.py @@ -23,9 +23,9 @@ def __init__(self, path_to_test_file): self.path_to_expected_output_dir = os.path.join( path_to_test_dir, "expected_output" ) - assert os.path.isdir( + assert os.path.isdir(self.path_to_expected_output_dir), ( self.path_to_expected_output_dir - ), self.path_to_expected_output_dir + ) # Sandbox is where the StrictDoc server will find its documents. self.path_to_sandbox = os.path.join(path_to_test_dir, ".sandbox") @@ -46,9 +46,9 @@ def path_to_expected_output_dir_file(self, file_name): path_to_expected_output_dir_file = os.path.join( self.path_to_expected_output_dir, file_name ) - assert os.path.isfile( + assert os.path.isfile(path_to_expected_output_dir_file), ( path_to_expected_output_dir_file - ), path_to_expected_output_dir_file + ) return path_to_expected_output_dir_file def compare_sandbox_and_expected_output(self): diff --git a/tests/end2end/helpers/components/confirm.py b/tests/end2end/helpers/components/confirm.py index 6d693c165..329edbb35 100644 --- a/tests/end2end/helpers/components/confirm.py +++ b/tests/end2end/helpers/components/confirm.py @@ -26,8 +26,7 @@ def assert_confirm_requirement_delete(self) -> None: def assert_confirm_section_delete(self) -> None: self.test_case.assert_element('//*[@data-testid="confirm-message"]') self.test_case.assert_element( - '//*[@data-testid="confirm-action"]' - '[contains(., "Delete section")]', + '//*[@data-testid="confirm-action"][contains(., "Delete section")]', by=By.XPATH, ) diff --git a/tests/end2end/helpers/components/node/document_root.py b/tests/end2end/helpers/components/node/document_root.py index 754f18266..673b9b9b5 100644 --- a/tests/end2end/helpers/components/node/document_root.py +++ b/tests/end2end/helpers/components/node/document_root.py @@ -32,8 +32,7 @@ def assert_root_node_is_editable(self) -> None: ) # should have the menu button (may be invisible) self.test_case.assert_element_present( - f"{self.node_xpath}" - "//*[@data-testid='document-edit-config-action']", + f"{self.node_xpath}//*[@data-testid='document-edit-config-action']", by=By.XPATH, ) diff --git a/tests/end2end/helpers/screens/document/form_edit_requirement.py b/tests/end2end/helpers/screens/document/form_edit_requirement.py index 0e6a58537..2651ede2d 100644 --- a/tests/end2end/helpers/screens/document/form_edit_requirement.py +++ b/tests/end2end/helpers/screens/document/form_edit_requirement.py @@ -96,9 +96,7 @@ def do_select_relation_role(self, mid: MID, field_value: str) -> None: assert isinstance(field_value, str) xpath = ( - f"(//*[@mid='{mid}' " - "and " - "@data-testid='select-relation-typerole'])" + f"(//*[@mid='{mid}' and @data-testid='select-relation-typerole'])" ) self.test_case.select_option_by_value(xpath, field_value) @@ -124,13 +122,13 @@ def do_fill_in_field_rationale(self, field_value: str) -> None: def assert_uid_field_contains(self, string: str) -> None: self.test_case.assert_element_present( - "//*[@data-testid='form-field-UID']" f"[contains(., '{string}')]", + f"//*[@data-testid='form-field-UID'][contains(., '{string}')]", by=By.XPATH, ) def assert_uid_field_does_not_contain(self, string: str) -> None: self.test_case.assert_element_not_present( - "//*[@data-testid='form-field-UID']" f"[contains(., '{string}')]", + f"//*[@data-testid='form-field-UID'][contains(., '{string}')]", by=By.XPATH, ) diff --git a/tests/end2end/helpers/screens/document/form_edit_section.py b/tests/end2end/helpers/screens/document/form_edit_section.py index 332b7f41b..68e2c216e 100644 --- a/tests/end2end/helpers/screens/document/form_edit_section.py +++ b/tests/end2end/helpers/screens/document/form_edit_section.py @@ -19,9 +19,9 @@ def do_fill_in_title(self, field_value: str) -> None: def do_fill_in_text(self, field_value: str) -> None: assert isinstance(field_value, str) - assert ( - len(field_value) > 0 - ), "To clear a text field, use do_clear_text() instead." + assert len(field_value) > 0, ( + "To clear a text field, use do_clear_text() instead." + ) super().do_fill_in("STATEMENT", field_value) def do_reset_uid_field(self, field_name: str = "") -> None: diff --git a/tests/end2end/helpers/screens/search/search.py b/tests/end2end/helpers/screens/search/search.py index 924ba0dae..96e905a91 100644 --- a/tests/end2end/helpers/screens/search/search.py +++ b/tests/end2end/helpers/screens/search/search.py @@ -16,7 +16,7 @@ def assert_nr_results(self, nr_results: int): else "Nothing matching the query was found." ) self.test_case.assert_element( - "//div[@class='sdoc-form-success']" f"[contains(., '{content}')]", + f"//div[@class='sdoc-form-success'][contains(., '{content}')]", by=By.XPATH, ) diff --git a/tests/end2end/screens/document/_cross_cutting/LINK_and_ANCHOR/node/_create/create_section_with_uid_and_node_with_LINK/test_case.py b/tests/end2end/screens/document/_cross_cutting/LINK_and_ANCHOR/node/_create/create_section_with_uid_and_node_with_LINK/test_case.py index 395325558..ec284c130 100644 --- a/tests/end2end/screens/document/_cross_cutting/LINK_and_ANCHOR/node/_create/create_section_with_uid_and_node_with_LINK/test_case.py +++ b/tests/end2end/screens/document/_cross_cutting/LINK_and_ANCHOR/node/_create/create_section_with_uid_and_node_with_LINK/test_case.py @@ -62,7 +62,7 @@ def test(self): ) form_edit_requirement.do_fill_in_field_title("Second title") form_edit_requirement.do_fill_in_field_statement( - "This is a text of the requirement." "\n\n" "[LINK: SECT-1]" + "This is a text of the requirement.\n\n[LINK: SECT-1]" ) form_edit_requirement.do_form_submit() diff --git a/tests/integration/features/commands/bypass/03_basic_document_test/input.sdoc b/tests/integration/features/commands/bypass/03_basic_document_test/input.sdoc new file mode 100644 index 000000000..f8f0f55de --- /dev/null +++ b/tests/integration/features/commands/bypass/03_basic_document_test/input.sdoc @@ -0,0 +1,8 @@ +[DOCUMENT] +TITLE: Hello world doc +UID: DOC-1 +VERSION: 1 +DATE: 2025-01-14 +CLASSIFICATION: TESTING +REQ_PREFIX: REQ- +ROOT: True diff --git a/tests/integration/features/commands/bypass/03_basic_document_test/test.itest b/tests/integration/features/commands/bypass/03_basic_document_test/test.itest new file mode 100644 index 000000000..7841c93b5 --- /dev/null +++ b/tests/integration/features/commands/bypass/03_basic_document_test/test.itest @@ -0,0 +1,2 @@ +RUN: %expect_exit 0 %strictdoc passthrough %S/input.sdoc --output-dir=%S/Output/ +RUN: %diff %S/input.sdoc %S/Output/sdoc/input.sdoc diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 50eaedf2a..1e5d0251f 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -7,9 +7,9 @@ from strictdoc.core.project_config import ProjectConfig strictdoc_root_path = os.path.abspath(os.path.join(__file__, "../../..")) -assert os.path.exists( - strictdoc_root_path -), f"does not exist: {strictdoc_root_path}" +assert os.path.exists(strictdoc_root_path), ( + f"does not exist: {strictdoc_root_path}" +) sys.path.append(strictdoc_root_path)