#539 Improve automatic test suite
Merged by onosek. Opened by oturpe.
oturpe/rpkg test-improvements  into  master

Download 539.patch
  1. In layout tests, remove duplicate assertions. No harmful, but unnecessary.
  2. In test_commands, when asserting rpmdefines, check that there are no other defines than expected.
  3. In test_cli, TestImportSrpm was failing because stdout had more than one row like the test case expected. Improved assert to compare only the last item of the last line of output, which should have the expected content. Depending on rpm version, there can be multipe lines of output, notably one like setting SOURCE_DATE_EPOCH=1136073600, and depending on locale settings, the last row can have more than two components when split by whitespace, because the line starts with localized tring "Wrote:", which may be translated to multiple works (arguably, a better fix would be to avoid using the current locale when running the tests - but since the same line of code needs changes anyhow, it makes sense to apply this simple fix now)

Also, fix a typo in a method description.

Signed-off-by: Otto Urpelainen oturpe@iki.fi

rebased onto 6d7293cf7bcbd8614a7bd9d7bd3f941933b55934

Thanks for your contribution! I like it. But I am trying to understand what was wrong regarding split(). In which situation/environment did you observe fail? For expected data

stdout = "x y\n"

both code versions, split() and splitlines(), are working. I tried it in various Python3 shells. What if ... are there two '\n\n' appended in your environment? In this case, splitlines() would solve it.

Good question. I ran the tests in Fedora 33, set to Finnish locale, using tox. I suppose tox is intended to isolate the tests from the environment, however that does not completely work, because a) rpkg makes external call to rpmbuild and b) the test case is relying on translated strings.

[otto@ottovain rpkg]$ uname -a
Linux ottovain 5.10.13-200.fc33.x86_64 #1 SMP Thu Feb 4 14:54:51 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
[otto@ottovain rpkg]$ rpmbuild --version
RPM versio 4.16.1.2

And the stdout in the test case is:

setting SOURCE_DATE_EPOCH=1136073600
Kirjoitettiin: /tmp/test-import-srpm-topdir-5r5aewpr/SRPMS/docpkg-0.2-1.fc33.src.rpm

Locale is not important here, though it could be for some other setting, depending on how "Wrote:" gets translated. In Finnish it is a single word, so all good. But the first line about SOURCE_DATE_EPOCH comes from the particular rpm version Fedora 33 has, I suppose.

Regarding using rpkg in Fedora (which happens, through fedpkg), I have on Fedora 33:

$ python --version
Python 3.9.1

I suppose this means that rpkg must support Python 3.9. I could add such configuration to tox.ini here if that sounds like a good idea.

rebased onto ed33853c40357521455151a7992ead66cce7c84f

rebased onto 7ea0af73ae05839a506b72bfdea1a75d99758d50

Locale is not important here, though it could be for some other setting, depending on how "Wrote:" gets translated. In Finnish it is a single word, so all good.

Talking with myself here. I checked if there is any translation that actually uses two words. It turns out that there is: vi_VN. Since the same line of code changes due to multiple lines of output issue anyhow, I fixed the word count issue, too.

Thanks for the explanation. Good catch with the translation.

Jenkinks finished: https://jenkins-fedora-infra.apps.ci.centos.org/job/pyrpkg/472/

Pull-Request has been merged by onosek

Metadata