This is tricky. Note the sys.path hack in test/unit/__init__.py where
we intentionally use the Fedora's default Python libraries with a
different Python version selected by Tox. Right now it means that we
use, e.g., python3-rpm compiled for Python 3.12 (F39) with Python 3.7
(which probably works because Tox is executed as root in the tox
container, overwriting the pre-compiled *.pyc files in container).
Some tests need to be skipped in Tox, therefore the skip_if_tox()
method.
Also, the GitHub's action for 'git checkout' provides somewhat
non-standard environment for Tito to work, hence the fix_tox_env()
configuration method.
- Some tests can not work at rpmbuild time, because we can not run
rpmbuild in rpmbuild, and there's no .git/ directory, skip.
- Use 'titodir' below 'srcdir', to not pollute the /tmp/tito dir.
- The test_colors() test requires color-friendly TERM env.
- EL7 is EOL, do not enable tests there.
- Requires us to add pytest.ini to tell pytest where to look for test
files, and set the python path.
- Mock drops terminal from the tested code, so we have to "mock" it in
test_colors()
- Enable coverage in tox tests.
The old output was missing filenames, e.g.
AssertionError: Found PEP8 errors that may break your code in Python 3:
2 E201 whitespace after '['
3 E202 whitespace before ']'
2 E203 whitespace before ':'
1 E221 multiple spaces before operator
1 E302 expected 2 blank lines, found 1
2 E303 too many blank lines (2)
That's now usefull at all. Where the heck should I search for these errors. The
new output is a little bit messy but contains more usefull information, e.g.
AssertionError: Found PEP8 errors that may break your code in Python 3:
/tito/test/unit/../../src/tito/release/LocalYumRepo.py:9:1: E302 expected 2 blank lines, found 1
/tito/test/unit/../../src/tito/release/LocalYumRepo.py:17:66: E202 whitespace before ']'
/tito/test/unit/../../src/tito/release/LocalYumRepo.py:21:15: E203 whitespace before ':'
/tito/test/unit/../../src/tito/release/LocalYumRepo.py:22:16: E203 whitespace before ':'
/tito/test/unit/../../src/tito/release/LocalYumRepo.py:26:18: E201 whitespace after '['
/tito/test/unit/../../src/tito/release/LocalYumRepo.py:26:32: E202 whitespace before ']'
/tito/test/unit/../../src/tito/release/LocalYumRepo.py:29:15: E201 whitespace after '['
/tito/test/unit/../../src/tito/release/LocalYumRepo.py:29:32: E202 whitespace before ']'
/tito/test/unit/../../src/tito/release/LocalYumRepo.py:35:17: E221 multiple spaces before operator
/tito/test/unit/../../src/tito/release/LocalYumRepo.py:76:5: E303 too many blank lines (2)
See RHBZ 1784688
We are using unversioned python macros, such as `%__python` and
`%python_sitelib` which are not supported in Fedora rawhide
anymore. Instead, we should use `%__python3` and `%python3_sitelib`.
Fix#364
Previously all non-yes input was considered to be "no". Which is not
what we typically want. There should be expected "yes" inputs, expected
"no" inputs and everything else should be considered to be an uknown
input and should be treated this way.
I think that printing an error for unknown input is too verbose and have
no added value. Simply repeating the question is the way to go here:
##### Please review the above diff #####
Do you wish to proceed with commit? [y/n] foo
Do you wish to proceed with commit? [y/n] y
Proceeding with commit.
It's better to do the python2 and python3 compatibility magic on
one place rather than having having `if PY2` conditions everywhere
and figuring whether to use `builtins.foo` or `__builtin__.foo
over and over again.
Fix#358
Previously the bugzilla-specific code was implemented in `tito.common`
which is imported from everywhere. Therefore missing dependency
to `python3-bugzilla` resulted in failure even for simple commands
such as `tito build --tgz`.
This partialy reverts commit 03509b36d5.
It removes just test and keep the functionality.
The test cannot be there right now because tito 0.6.11 and older will choke on this and will produce demaged tarball.
This revert can be added back later when all devel has tito in version 0.6.12 or higher.
Resolves: #337
Following the principals of https://nedbatchelder.com/text/unipain.html
our goal is to decode bytes in to unicode as soon as we read them and
encode unicode date to bytes at the last second.
The specific problem we were seeing was caused by calling "encode" on a
byte string rather than a unicode string. Python attempts to be
"helpful" and tries to decode the bytes as ASCII in order to provide a
unicode string to the encode function. Since the bytes aren't ASCII,
the decode fails and we get the UnicodeDecodeError despite the fact that
we never explicitly asked for a decode at all.
Also, calculate checksums correctly for tarballs that have files with
UTF8 characters in the file name.
CentOS 6 only has Python 2.6 available, on which the unit testing
frameworks do not expose a `.assertIn()` helper method. Instead, we can
use `.assertTrue(x in y)`.
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
When tests fail, artifacts from that tests are necessary to properly
debug the failure and determine how to fix the test. This is impossible
when artifacts are immediately removed after the test is finished.
Instead, the tests should remove old artifacts before the test run
begins.
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
When multiple tags exist for one version of a project, or when a version
is passed to `tito tag --use-version` that does not exactly correspond
with a tag in the repository's git history, the auto-generated release
is not guaranteed to monotonically increase. In order for users to
overcome this issue without building complicated logic into `tito`, it
is simpler to allow users to provide a literal release string to use.
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
By using a user specific URL, multiple members of the same team can
submit Copr releases without having to share credentials to the SRPM
remote location. For example, each member of the team can set
COPR_REMOTE_LOCATION in .titorc to their <username>.fedorapeople.org
space.