Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-specfile for openSUSE:Factory checked in at 2023-02-06 14:15:54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-specfile (Old) and /work/SRC/openSUSE:Factory/.python-specfile.new.4462 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-specfile" Mon Feb 6 14:15:54 2023 rev:7 rq:1063412 version:0.13.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-specfile/python-specfile.changes 2023-01-24 20:33:32.180754895 +0100 +++ /work/SRC/openSUSE:Factory/.python-specfile.new.4462/python-specfile.changes 2023-02-06 14:15:57.192743385 +0100 @@ -1,0 +2,7 @@ +Mon Feb 6 06:32:11 UTC 2023 - David Anes <david.a...@suse.com> + +- Update to version 0.13.2: + * Fixed infinite loop that occured when section options were + followed by whitespace. + +------------------------------------------------------------------- Old: ---- specfile-0.13.1.tar.gz New: ---- specfile-0.13.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-specfile.spec ++++++ --- /var/tmp/diff_new_pack.mb3JkK/_old 2023-02-06 14:15:57.772746687 +0100 +++ /var/tmp/diff_new_pack.mb3JkK/_new 2023-02-06 14:15:57.788746778 +0100 @@ -18,7 +18,7 @@ %define skip_python38 1 Name: python-specfile -Version: 0.13.1 +Version: 0.13.2 Release: 0 Summary: A library for parsing and manipulating RPM spec files License: MIT ++++++ specfile-0.13.1.tar.gz -> specfile-0.13.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/.pre-commit-config.yaml new/specfile-0.13.2/.pre-commit-config.yaml --- old/specfile-0.13.1/.pre-commit-config.yaml 2023-01-23 15:57:25.000000000 +0100 +++ new/specfile-0.13.2/.pre-commit-config.yaml 2023-01-30 14:24:54.000000000 +0100 @@ -4,19 +4,19 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.1.0 + rev: v3.3.1 hooks: - id: pyupgrade - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 22.12.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.3 + rev: v3.0.0-alpha.4 hooks: - id: prettier - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-added-large-files - id: check-ast @@ -31,7 +31,7 @@ - id: mixed-line-ending - id: trailing-whitespace - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 args: @@ -39,12 +39,12 @@ # https://github.com/PyCQA/pycodestyle/issues/373 - --extend-ignore=E203 - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.11.5 hooks: - id: isort args: [--profile, black] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.982 + rev: v0.991 hooks: - id: mypy args: [--show-error-codes, --ignore-missing-imports] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/CHANGELOG.md new/specfile-0.13.2/CHANGELOG.md --- old/specfile-0.13.1/CHANGELOG.md 2023-01-23 15:57:25.000000000 +0100 +++ new/specfile-0.13.2/CHANGELOG.md 2023-01-30 14:24:54.000000000 +0100 @@ -1,3 +1,7 @@ +# 0.13.2 + +- Fixed infinite loop that occured when section options were followed by whitespace. (#197) + # 0.13.1 - Fixed a bug in section parsing that caused sections to be ignored when there were macro definitions spread across the spec file and not cumulated at the top. (#191) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/PKG-INFO new/specfile-0.13.2/PKG-INFO --- old/specfile-0.13.1/PKG-INFO 2023-01-23 15:57:38.926413300 +0100 +++ new/specfile-0.13.2/PKG-INFO 2023-01-30 14:25:04.099290000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: specfile -Version: 0.13.1 +Version: 0.13.2 Summary: A library for parsing and manipulating RPM spec files. Home-page: https://github.com/packit/specfile Author: Red Hat diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/fedora/python-specfile.spec new/specfile-0.13.2/fedora/python-specfile.spec --- old/specfile-0.13.1/fedora/python-specfile.spec 2023-01-23 15:57:25.000000000 +0100 +++ new/specfile-0.13.2/fedora/python-specfile.spec 2023-01-30 14:24:54.000000000 +0100 @@ -13,7 +13,7 @@ Name: python-specfile -Version: 0.13.1 +Version: 0.13.2 Release: 1%{?dist} Summary: A library for parsing and manipulating RPM spec files @@ -69,6 +69,9 @@ %changelog +* Mon Jan 30 2023 Packit Team <he...@packit.dev> - 0.13.2-1 +- New upstream release 0.13.2 + * Mon Jan 23 2023 Packit Team <he...@packit.dev> - 0.13.1-1 - New upstream release 0.13.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/specfile/changelog.py new/specfile-0.13.2/specfile/changelog.py --- old/specfile-0.13.1/specfile/changelog.py 2023-01-23 15:57:25.000000000 +0100 +++ new/specfile-0.13.2/specfile/changelog.py 2023-01-30 14:24:54.000000000 +0100 @@ -331,11 +331,14 @@ content: List[str] = [] for line in section: if line.startswith("*"): - if header: - following_lines = extract_following_lines(content) - data.insert(0, ChangelogEntry(header, content, following_lines)) - header = line - content = [] + if header is None or "".join(content).strip(): + if header: + following_lines = extract_following_lines(content) + data.insert(0, ChangelogEntry(header, content, following_lines)) + header = line + content = [] + else: + content.append(line) elif header: content.append(line) else: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/specfile/options.py new/specfile-0.13.2/specfile/options.py --- old/specfile-0.13.1/specfile/options.py 2023-01-23 15:57:25.000000000 +0100 +++ new/specfile-0.13.2/specfile/options.py 2023-01-30 14:24:54.000000000 +0100 @@ -512,6 +512,9 @@ if not c.isspace(): break whitespace += c + else: + result.append(Token(TokenType.WHITESPACE, whitespace)) + break inp.insert(0, c) result.append(Token(TokenType.WHITESPACE, whitespace)) continue diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/specfile/sources.py new/specfile-0.13.2/specfile/sources.py --- old/specfile-0.13.1/specfile/sources.py 2023-01-23 15:57:25.000000000 +0100 +++ new/specfile-0.13.2/specfile/sources.py 2023-01-30 14:24:54.000000000 +0100 @@ -2,33 +2,17 @@ # SPDX-License-Identifier: MIT import collections -import copy import re import urllib.parse from abc import ABC, abstractmethod -from typing import ( - TYPE_CHECKING, - Any, - Dict, - Iterable, - List, - Optional, - Tuple, - Union, - cast, - overload, -) +from typing import Iterable, List, Optional, Tuple, Union, cast, overload from specfile.exceptions import DuplicateSourceException from specfile.formatter import formatted -from specfile.macros import Macros from specfile.sourcelist import Sourcelist, SourcelistEntry from specfile.tags import Comments, Tag, Tags from specfile.utils import get_filename_from_location -if TYPE_CHECKING: - from specfile.specfile import Specfile - class Source(ABC): """Class that represents a source.""" @@ -252,7 +236,6 @@ allow_duplicates: bool = False, default_to_implicit_numbering: bool = False, default_source_number_digits: int = 1, - context: Optional["Specfile"] = None, ) -> None: """ Constructs a `Sources` object. @@ -273,7 +256,6 @@ self._allow_duplicates = allow_duplicates self._default_to_implicit_numbering = default_to_implicit_numbering self._default_source_number_digits = default_source_number_digits - self._context = context def __eq__(self, other: object) -> bool: if not isinstance(other, Sources): @@ -295,19 +277,9 @@ return ( f"{self.__class__.__name__}({self._tags!r}, {self._sourcelists!r}, " f"{self._allow_duplicates!r}, {self._default_to_implicit_numbering!r}, " - f"{self._default_source_number_digits!r}, {self._context!r})" + f"{self._default_source_number_digits!r})" ) - def __deepcopy__(self, memo: Dict[int, Any]) -> "Sources": - result = self.__class__.__new__(self.__class__) - memo[id(self)] = result - for k, v in self.__dict__.items(): - if k == "_context": - continue - setattr(result, k, copy.deepcopy(v, memo)) - result._context = self._context - return result - def __contains__(self, location: object) -> bool: items = self._get_items() if not items: @@ -364,11 +336,6 @@ _, container, index = items[i] del container[index] - def _expand(self, s: str) -> str: - if self._context: - return self._context.expand(s) - return Macros.expand(s) - def _get_tags(self) -> List[Tuple[TagSource, Tags, int]]: """ Gets all tag sources. @@ -535,7 +502,7 @@ name, separator = self._get_tag_format(cast(TagSource, source), number) container.insert( index, - Tag(name, location, self._expand(location), separator, Comments()), + Tag(name, location, separator, Comments()), ) self._deduplicate_tag_names(i) else: @@ -549,7 +516,7 @@ index, name, separator = self._get_initial_tag_setup() self._tags.insert( index, - Tag(name, location, self._expand(location), separator, Comments()), + Tag(name, location, separator, Comments()), ) def insert_numbered(self, number: int, location: str) -> int: @@ -582,9 +549,7 @@ else: i = 0 index, name, separator = self._get_initial_tag_setup(number) - self._tags.insert( - index, Tag(name, location, self._expand(location), separator, Comments()) - ) + self._tags.insert(index, Tag(name, location, separator, Comments())) self._deduplicate_tag_names(i) return i diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/specfile/specfile.py new/specfile-0.13.2/specfile/specfile.py --- old/specfile-0.13.1/specfile/specfile.py 2023-01-23 15:57:25.000000000 +0100 +++ new/specfile-0.13.2/specfile/specfile.py 2023-01-30 14:24:54.000000000 +0100 @@ -7,7 +7,7 @@ import types from dataclasses import dataclass from pathlib import Path -from typing import Generator, List, Optional, Tuple, Type, Union +from typing import Generator, List, Optional, Tuple, Type, Union, cast import rpm @@ -257,17 +257,13 @@ Tags in the section as `Tags` object. """ with self.sections() as sections: - if isinstance(section, Section): - raw_section = section - parsed_section = getattr(self.parsed_sections, section.id, None) - else: - raw_section = getattr(sections, section) - parsed_section = getattr(self.parsed_sections, section, None) - tags = Tags.parse(raw_section, parsed_section) + if isinstance(section, str): + section = cast(Section, getattr(sections, section)) + tags = Tags.parse(section, context=self) try: yield tags finally: - raw_section.data = tags.get_raw_section_data() + section.data = tags.get_raw_section_data() @ContextManager def changelog(self) -> Generator[Optional[Changelog], None, None]: @@ -340,7 +336,6 @@ allow_duplicates, default_to_implicit_numbering, default_source_number_digits, - context=self, ) finally: for section, sourcelist in sourcelists: @@ -377,7 +372,6 @@ allow_duplicates, default_to_implicit_numbering, default_source_number_digits, - context=self, ) finally: for section, patchlist in patchlists: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/specfile/tags.py new/specfile-0.13.2/specfile/tags.py --- old/specfile-0.13.1/specfile/tags.py 2023-01-23 15:57:25.000000000 +0100 +++ new/specfile-0.13.2/specfile/tags.py 2023-01-30 14:24:54.000000000 +0100 @@ -5,13 +5,28 @@ import copy import itertools import re -from typing import Any, Iterable, List, Optional, SupportsIndex, Union, cast, overload +from typing import ( + TYPE_CHECKING, + Any, + Dict, + Iterable, + List, + Optional, + SupportsIndex, + Union, + cast, + overload, +) from specfile.constants import TAG_NAMES, TAGS_WITH_ARG from specfile.formatter import formatted +from specfile.macros import Macros from specfile.sections import Section from specfile.utils import split_conditional_macro_expansion +if TYPE_CHECKING: + from specfile.specfile import Specfile + def get_tag_name_regex(name: str) -> str: """Contructs regex corresponding to the specified tag name.""" @@ -195,11 +210,11 @@ self, name: str, value: str, - expanded_value: Optional[str], separator: str, comments: Comments, prefix: Optional[str] = None, suffix: Optional[str] = None, + context: Optional["Specfile"] = None, ) -> None: """ Constructs a `Tag` object. @@ -214,6 +229,7 @@ comments: List of comments associated with the tag. prefix: Characters preceding the tag on a line. suffix: Characters following the tag on a line. + context: `Specfile` instance that defines the context for macro expansions. Returns: Constructed instance of `Tag` class. @@ -225,11 +241,11 @@ raise ValueError(f"Invalid tag name: '{name}'") self.name = name self.value = value - self._expanded_value = expanded_value self._separator = separator self.comments = comments.copy() self._prefix = prefix or "" self._suffix = suffix or "" + self._context = context def __eq__(self, other: object) -> bool: if not isinstance(other, Tag): @@ -237,7 +253,6 @@ return ( self.name == other.name and self.value == other.value - and self._expanded_value == other._expanded_value and self._separator == other._separator and self.comments == other.comments and self._prefix == other._prefix @@ -247,10 +262,20 @@ @formatted def __repr__(self) -> str: return ( - f"Tag({self.name!r}, {self.value!r}, {self._expanded_value!r}, " - f"{self._separator!r}, {self.comments!r}, {self._prefix!r}, {self._suffix!r})" + f"Tag({self.name!r}, {self.value!r}, {self._separator!r}, {self.comments!r}, " + f"{self._prefix!r}, {self._suffix!r}, {self._context!r})" ) + def __deepcopy__(self, memo: Dict[int, Any]) -> "Tag": + result = self.__class__.__new__(self.__class__) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k == "_context": + continue + setattr(result, k, copy.deepcopy(v, memo)) + result._context = self._context + return result + @property def normalized_name(self) -> str: """ @@ -260,14 +285,11 @@ return self.name.capitalize() @property - def valid(self) -> bool: - """Validity of the tag. A tag is valid if it 'survives' the expansion of the spec file.""" - return self._expanded_value is not None - - @property def expanded_value(self) -> Optional[str]: - """Value of the tag after expanding macros and evaluating all conditions.""" - return self._expanded_value + """Value of the tag after expanding macros.""" + if self._context: + return self._context.expand(self.value) + return Macros.expand(self.value) def get_position(self, container: "Tags") -> int: """ @@ -358,13 +380,13 @@ reversed( list( itertools.dropwhile( - lambda l: not l, reversed(preceding_lines) + lambda line: not line, reversed(preceding_lines) ) ) ) ) + delimiter - + list(itertools.dropwhile(lambda l: not l, lines)) + + list(itertools.dropwhile(lambda line: not line, lines)) ) if isinstance(i, slice): @@ -434,15 +456,13 @@ del lines[: index + 1] @classmethod - def parse( - cls, raw_section: Section, parsed_section: Optional[Section] = None - ) -> "Tags": + def parse(cls, section: Section, context: Optional["Specfile"] = None) -> "Tags": """ Parses a section into tags. Args: - raw_section: Raw (unprocessed) section. - parsed_section: The same section after parsing. + section: Section to parse. + context: `Specfile` instance that defines the context for macro expansions. Returns: Constructed instance of `Tags` class. @@ -455,31 +475,20 @@ tag_regexes = [re.compile(regex_pattern(t), re.IGNORECASE) for t in TAG_NAMES] data = [] buffer: List[str] = [] - for line in raw_section: + for line in section: line, prefix, suffix = split_conditional_macro_expansion(line) # find out if there is a match for one of the tag regexes m = next((m for m in (r.match(line) for r in tag_regexes) if m), None) if m: - # find out if any line in the parsed section matches the same regex - tag_regex = re.compile(regex_pattern(m.group("n"))) - e = next( - ( - e - for e in (tag_regex.match(pl) for pl in parsed_section or []) - if e - ), - None, - ) - expanded_value = e.group("v") if e else None data.append( Tag( m.group("n"), m.group("v"), - expanded_value, m.group("s"), Comments.parse(buffer), prefix, suffix, + context, ) ) buffer = [] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/specfile.egg-info/PKG-INFO new/specfile-0.13.2/specfile.egg-info/PKG-INFO --- old/specfile-0.13.1/specfile.egg-info/PKG-INFO 2023-01-23 15:57:38.000000000 +0100 +++ new/specfile-0.13.2/specfile.egg-info/PKG-INFO 2023-01-30 14:25:04.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: specfile -Version: 0.13.1 +Version: 0.13.2 Summary: A library for parsing and manipulating RPM spec files. Home-page: https://github.com/packit/specfile Author: Red Hat diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/tests/integration/test_specfile.py new/specfile-0.13.2/tests/integration/test_specfile.py --- old/specfile-0.13.1/tests/integration/test_specfile.py 2023-01-23 15:57:25.000000000 +0100 +++ new/specfile-0.13.2/tests/integration/test_specfile.py 2023-01-30 14:24:54.000000000 +0100 @@ -430,7 +430,6 @@ assert not spec.expand("%patches") with spec.tags() as tags: assert tags.provides.value.startswith("%(") - assert tags.provides.expanded_value == "DUMMY-0.1" with spec.sections() as sections: assert sections.description[0] == "%include %{SOURCE3}" assert sections.description[1] == "%(cat %{S:4})" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/tests/unit/test_changelog.py new/specfile-0.13.2/tests/unit/test_changelog.py --- old/specfile-0.13.1/tests/unit/test_changelog.py 2023-01-23 15:57:25.000000000 +0100 +++ new/specfile-0.13.2/tests/unit/test_changelog.py 2023-01-30 14:24:54.000000000 +0100 @@ -141,6 +141,13 @@ Section( "changelog", data=[ + "* Fri Jan 27 2023 Nikola Forró <nfo...@redhat.com> - 0.4-1", + "", + "* this is also a valid entry", + "", + "* Fri Jan 27 2023 Nikola Forró <nfo...@redhat.com> - 0.3-2", + "* this is a valid entry", + "", "* Mon Nov 21 2022 Nikola Forró <nfo...@redhat.com> - 0.3-1", "- this is a formatted", " changelog entry", @@ -162,7 +169,7 @@ ], ) ) - assert len(changelog) == 5 + assert len(changelog) == 7 assert ( changelog[0].header == "* Tue May 04 2021 Nikola Forró <nfo...@redhat.com> - 0.1-1" @@ -200,6 +207,23 @@ "- here is another item", ] assert not changelog[4].extended_timestamp + assert ( + changelog[5].header + == "* Fri Jan 27 2023 Nikola Forró <nfo...@redhat.com> - 0.3-2" + ) + assert changelog[5].content == [ + "* this is a valid entry", + ] + assert not changelog[5].extended_timestamp + assert ( + changelog[6].header + == "* Fri Jan 27 2023 Nikola Forró <nfo...@redhat.com> - 0.4-1" + ) + assert changelog[6].content == [ + "", + "* this is also a valid entry", + ] + assert not changelog[6].extended_timestamp def test_get_raw_section_data(): @@ -242,9 +266,33 @@ ], "0.3-1", ), + ChangelogEntry.assemble( + datetime.date(2023, 1, 27), + "Nikola Forró <nfo...@redhat.com>", + [ + "* this is a valid entry", + ], + "0.3-2", + ), + ChangelogEntry.assemble( + datetime.date(2023, 1, 27), + "Nikola Forró <nfo...@redhat.com>", + [ + "", + "* this is also a valid entry", + ], + "0.4-1", + ), ] ) assert changelog.get_raw_section_data() == [ + "* Fri Jan 27 2023 Nikola Forró <nfo...@redhat.com> - 0.4-1", + "", + "* this is also a valid entry", + "", + "* Fri Jan 27 2023 Nikola Forró <nfo...@redhat.com> - 0.3-2", + "* this is a valid entry", + "", "* Mon Nov 21 2022 Nikola Forró <nfo...@redhat.com> - 0.3-1", "- this is a formatted", " changelog entry", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/tests/unit/test_options.py new/specfile-0.13.2/tests/unit/test_options.py --- old/specfile-0.13.1/tests/unit/test_options.py 2023-01-23 15:57:25.000000000 +0100 +++ new/specfile-0.13.2/tests/unit/test_options.py 2023-01-30 14:24:54.000000000 +0100 @@ -233,6 +233,21 @@ Token(TokenType.DOUBLE_QUOTED, '.test "double quotes"'), ], ), + ( + "-p1 -b .test_whitespace_at_the_end -M 2 ", + [ + Token(TokenType.DEFAULT, "-p1"), + Token(TokenType.WHITESPACE, " "), + Token(TokenType.DEFAULT, "-b"), + Token(TokenType.WHITESPACE, " "), + Token(TokenType.DEFAULT, ".test_whitespace_at_the_end"), + Token(TokenType.WHITESPACE, " "), + Token(TokenType.DEFAULT, "-M"), + Token(TokenType.WHITESPACE, " "), + Token(TokenType.DEFAULT, "2"), + Token(TokenType.WHITESPACE, " "), + ], + ), ], ) def test_options_tokenize(option_string, result): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/tests/unit/test_sources.py new/specfile-0.13.2/tests/unit/test_sources.py --- old/specfile-0.13.1/tests/unit/test_sources.py 2023-01-23 15:57:25.000000000 +0100 +++ new/specfile-0.13.2/tests/unit/test_sources.py 2023-01-30 14:24:54.000000000 +0100 @@ -23,7 +23,7 @@ ], ) def test_tag_source_extract_number(tag_name, number): - ts = TagSource(Tag(tag_name, "", "", "", Comments())) + ts = TagSource(Tag(tag_name, "", "", Comments())) assert ts._extract_number() == number @@ -74,7 +74,7 @@ ) def test_sources_detect_implicit_numbering(tags, default, result): sources = Sources( - Tags([Tag(t, v, v, ": ", Comments()) for t, v in tags]), + Tags([Tag(t, v, ": ", Comments()) for t, v in tags]), [], default_to_implicit_numbering=default, ) @@ -91,7 +91,7 @@ ) def test_sources_get_tag_format(ref_name, ref_separator, number, name, separator): sources = Sources(Tags(), []) - reference = TagSource(Tag(ref_name, "", "", ref_separator, Comments())) + reference = TagSource(Tag(ref_name, "", ref_separator, Comments())) assert sources._get_tag_format(reference, number) == (name, separator) @@ -103,9 +103,7 @@ ], ) def test_sources_get_initial_tag_setup(tags, number, index): - sources = Sources( - Tags([Tag(t, "test", "test", ": ", Comments()) for t in tags]), [] - ) + sources = Sources(Tags([Tag(t, "test", ": ", Comments()) for t in tags]), []) assert sources._get_initial_tag_setup(number) == (index, f"Source{number}", ": ") @@ -153,9 +151,7 @@ ], ) def test_sources_deduplicate_tag_names(tags, deduplicated_tags): - sources = Sources( - Tags([Tag(t, "test", "test", ": ", Comments()) for t in tags]), [] - ) + sources = Sources(Tags([Tag(t, "test", ": ", Comments()) for t in tags]), []) sources._deduplicate_tag_names() assert [t.name for t in sources._tags] == deduplicated_tags @@ -242,7 +238,7 @@ ) def test_sources_insert(tags, sourcelists, index, location, number, cls): sources = Sources( - Tags([Tag(t, v, v, ": ", Comments()) for t, v in tags]), + Tags([Tag(t, v, ": ", Comments()) for t, v in tags]), [ Sourcelist([SourcelistEntry(s, Comments()) for s in sl]) for sl in sourcelists @@ -334,7 +330,7 @@ ], ) def test_sources_insert_numbered(tags, number, location, index): - sources = Sources(Tags([Tag(t, v, v, ": ", Comments()) for t, v in tags]), []) + sources = Sources(Tags([Tag(t, v, ": ", Comments()) for t, v in tags]), []) if location in [v for t, v in tags if t.startswith(Sources.prefix)]: with pytest.raises(SpecfileException): sources.insert_numbered(number, location) @@ -401,13 +397,13 @@ ], ) def test_sources_remove_numbered(tags, sourcelists, number, new_tags, new_sourcelists): - tags = Tags([Tag(t, v, v, ": ", Comments()) for t, v in tags]) + tags = Tags([Tag(t, v, ": ", Comments()) for t, v in tags]) sourcelists = [ Sourcelist([SourcelistEntry(s, Comments()) for s in sl]) for sl in sourcelists ] sources = Sources(tags, sourcelists) sources.remove_numbered(number) - assert tags == Tags([Tag(t, v, v, ": ", Comments()) for t, v in new_tags]) + assert tags == Tags([Tag(t, v, ": ", Comments()) for t, v in new_tags]) assert sourcelists == [ Sourcelist([SourcelistEntry(s, Comments()) for s in sl]) for sl in new_sourcelists @@ -425,7 +421,7 @@ ) def test_patches_get_tag_format(ref_name, ref_separator, number, name, separator): patches = Patches(Tags(), []) - reference = TagSource(Tag(ref_name, "", "", ref_separator, Comments())) + reference = TagSource(Tag(ref_name, "", ref_separator, Comments())) assert patches._get_tag_format(reference, number) == (name, separator) @@ -439,9 +435,7 @@ ], ) def test_patches_get_initial_tag_setup(tags, number, index): - patches = Patches( - Tags([Tag(t, "test", "test", ": ", Comments()) for t in tags]), [] - ) + patches = Patches(Tags([Tag(t, "test", ": ", Comments()) for t in tags]), []) flexmock(patches).should_receive("_get_tag_format").and_return( f"Patch{number}", ": " ) @@ -450,7 +444,7 @@ def test_copy_sources(): sources = Sources( - Tags([Tag("Name", "test", "test", ": ", Comments())]), + Tags([Tag("Name", "test", ": ", Comments())]), [ Sourcelist([SourcelistEntry("%{name}-%{version}.tar.gz", Comments())]), ], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.13.1/tests/unit/test_tags.py new/specfile-0.13.2/tests/unit/test_tags.py --- old/specfile-0.13.1/tests/unit/test_tags.py 2023-01-23 15:57:25.000000000 +0100 +++ new/specfile-0.13.2/tests/unit/test_tags.py 2023-01-30 14:24:54.000000000 +0100 @@ -12,9 +12,9 @@ def test_find(): tags = Tags( [ - Tag("Name", "test", "test", ": ", Comments()), - Tag("Version", "0.1", "0.1", ": ", Comments()), - Tag("Release", "1%{?dist}", "1.fc35", ": ", Comments()), + Tag("Name", "test", ": ", Comments()), + Tag("Version", "0.1", ": ", Comments()), + Tag("Release", "1%{?dist}", ": ", Comments()), ] ) assert tags.find("version") == 1 @@ -44,47 +44,28 @@ "Requires: make", "Requires(post): bash", "", - "%{?fedora:Suggests: diffutils}", - ], - ), - Section( - "package", - data=[ - "", - "", - "", - "# this is a test package", - "# not to be used in production", - "Name: test", - "Version: 1.0", - " # this is a valid comment", - "Release: 1.fc35", + "Provides: testX = %{version}-%{release}", + "Provides: bundled(superlib) = 2.42.0", "", - "", - "", - "", - "", - "Requires: make", - "Requires(post): bash", - "", - "Suggests: diffutils", + "%{?fedora:Suggests: diffutils}", ], - ), + ) ) assert tags[0].name == "Name" assert tags[0].comments[0].text == "this is a test package" assert tags[0].comments[1].text == "not to be used in production" assert tags[1].name == "Version" assert tags[1].value == "%{ver_major}.%{ver_minor}" - assert tags[1].valid - assert tags[1].expanded_value == "1.0" assert not tags[1].comments assert tags.release.comments[0].prefix == " # " assert tags.epoch.name == "Epoch" - assert not tags.epoch.valid assert tags.requires.value == "make" assert "requires(post)" in tags - assert tags[-2].name == "Requires(post)" + assert tags[-4].name == "Requires(post)" + assert tags[-3].name == "Provides" + assert tags[-3].value == "testX = %{version}-%{release}" + assert tags[-2].name == "Provides" + assert tags[-2].value == "bundled(superlib) = 2.42.0" assert tags[-1].name == "Suggests" assert tags.suggests.value == "diffutils" @@ -95,7 +76,6 @@ Tag( "Name", "test", - "test", ": ", Comments( [ @@ -105,23 +85,19 @@ ["%global ver_major 1", "%global ver_minor 0", ""], ), ), - Tag("Version", "%{ver_major}.%{ver_minor}", "1.0", ": ", Comments()), + Tag("Version", "%{ver_major}.%{ver_minor}", ": ", Comments()), Tag( "Release", "1%{?dist}", - "1.fc35", ": ", Comments([Comment("this is a valid comment", " # ")]), ), - Tag("Epoch", "1", "", ": ", Comments([], ["", "%if 0"])), - Tag( - "Requires", "make", "make", ": ", Comments([], ["%endif", ""]) - ), - Tag("Requires(post)", "bash", "bash", ": ", Comments()), + Tag("Epoch", "1", ": ", Comments([], ["", "%if 0"])), + Tag("Requires", "make", ": ", Comments([], ["%endif", ""])), + Tag("Requires(post)", "bash", ": ", Comments()), Tag( "Suggests", "diffutils", - "diffutils", ": ", Comments([], [""]), "%{?fedora:", @@ -155,7 +131,7 @@ def test_copy_tags(): tags = Tags( [ - Tag("Name", "test", "test", ": ", Comments()), + Tag("Name", "test", ": ", Comments()), ] ) shallow_copy = copy.copy(tags)