Commit graph

76 commits

Author SHA1 Message Date
Pavel Raiskup
d220002bf0 tests: unittests assertEquals() is now assertEqual() 2024-11-06 11:19:55 +01:00
Pavel Raiskup
b895acb7db tests: modernize import statements 2024-11-06 11:19:55 +01:00
Jakub Kadlcik
2ad7a823dd Replace egrep with grep -E
egrep: warning: egrep is obsolescent; using grep -E
2023-08-14 14:15:32 +02:00
Jakub Kadlcik
d41626d181 Print filenames that doesn't comply PEP8
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)
2021-01-12 16:27:27 +01:00
Jakub Kadlčík
27cb63e043
Merge pull request #374 from FrostyX/less-aggressive-yes-or-no
Make yes or no input less aggressive
2020-05-04 10:55:53 +02:00
Jakub Kadlcik
ad74e00a77 Make yes or no input less aggressive
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.
2020-04-26 14:13:35 +02:00
Jakub Kadlcik
ecd5718f62 Define a small abstraction for mocking builtins
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.
2020-04-26 14:13:35 +02:00
Jakub Kadlcik
3a62bb6613 Move bugzilla code to a separate file
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`.
2020-04-24 18:22:17 +02:00
Jakub Kadlcik
219efc50a2 Add a possibility to have full datetime entries in changelog
Fix #305

Unfortunatelly we need to use `pytz` instead of `datetime.timezone`
because of python2.
2020-04-24 17:41:00 +02:00
Jakub Kadlcik
a72d4fbe50 Move is_rawhide and is_epel6 definitions to __init__ so other tests can use it 2020-04-23 11:35:03 +02:00
Jakub Kadlčík
3bb01ebb56
Merge pull request #333 from evgeni/get_project_name
make get_project_name more resilient
2020-03-09 10:40:17 +01:00
Evgeni Golov
fef2cfd161 add tests for get_package_name 2020-01-31 14:08:10 +01:00
Jakub Kadlcik
8afe478b97 Temporarily disable checks for E7 and W6 2020-01-30 23:31:36 +01:00
Jakub Kadlcik
30f59ec027 Use pycodestyle pacakge when pep8 is not available 2020-01-30 23:31:34 +01:00
Ernestas Kulik
3a79fdde9f Move to python-blessed
As python-blessings is unmaintained nowadays and is not packaged for
EPEL 8, it might be good to move to an active fork.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1777377
2020-01-13 09:04:38 +01:00
Miroslav Suchý
9c3f00f2cf Partial revert "Fix #335. Handle source tarballs with UTF8 characters in the name."
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
2019-10-03 09:35:24 +02:00
Alex Wood
03509b36d5 Fix #335. Handle source tarballs with UTF8 characters in the name.
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.
2019-04-10 14:20:02 -04:00
Patrice Fournier
2a89594819 Don't append 'None' to Release line with no '%{?dist}' part 2017-08-29 09:28:09 -04:00
Martin Sehnoutka
074b129ad7 Fix unit tests. 2016-12-15 15:05:25 +01:00
Martin Sehnoutka
f7014b7527 Rename CargoTagger as CargoBump 2016-11-30 16:19:48 +01:00
Sehny
9bc7a0f76f fix few pep8 errors 2016-11-21 18:51:34 +01:00
Sehny
5da7997995 2 unit tests for cargo tagger. 2016-11-21 18:16:05 +01:00
Sehny
0efa60a77b Add unit test class 2016-11-21 13:31:31 +01:00
Devan Goodwin
5d258e7d2e Fix bugs with %autosetup and --test builds.
Extract method, add some tests, and fixed the regex problem.
2016-04-14 16:08:34 -03:00
Alex Wood
593f702372 Provide ability to turn off colored output. Fixes #182. 2015-06-15 11:02:18 -04:00
Alex Wood
356184c428 Correct style errors and use all caps for user_config option. 2015-06-12 13:36:25 -04:00
Alex Wood
d73ab2d661 Replace old Perl script for munging RPM release number. 2015-06-10 18:31:36 -04:00
Alex Wood
9b1d1c6988 Silence spurious test output. 2015-06-04 17:50:33 -04:00
Alex Wood
a5b43b6b96 Fix Python 3 issues with binary versus string types.
Python 3 is very picky about not mixing binary and string data.  This
patch gets TarFixer running on both Python 2.6+ and Python 3.x.
2015-05-18 14:01:43 -04:00
Alex Wood
07d62cf24e Tell the developer which PEP8 failures were detected. 2015-05-18 14:01:43 -04:00
Alex Wood
a8514c4dda Correct Python version incompatibilities. 2015-05-18 14:01:43 -04:00
Alex Wood
6fedf5850e Fix failing unit tests.
These tests began failing after a correction to another test.  The
other test had been patching the error_out function without unpatching
it and thus polluted the test environment.

Also reset to a known directory at the beginning of the common tests so
that we don't start in a directory that has since been unlinked.
2015-05-18 14:01:43 -04:00
Alex Wood
4882412610 Alter tar module to correct headers on a Maven-generated tar.
The Maven-generated tar file deviates from the spec in several places.
Fields are padded out with spaces instead of NUL bytes and the user and
group ID are left empty.

This patch alters the tar module to correct these issues and ensures a
consistent unchanging fingerprint for the archive by setting the mtime
on the files to the modified time of the commit.
2015-05-18 14:01:43 -04:00
Alex Wood
b00cb06937 Place the pickle file used for Cheetah in the build directory. 2015-05-18 14:01:36 -04:00
Alex Wood
b0e85268c9 Add flake8 configuration. Fix style issues.
- Remove assignments to unused variables
- Rename variables shadowing builtins
- Fix all flake8 errors in tests
2015-05-18 14:00:19 -04:00
Alex Wood
ea0ea51552 Unit test new common functions and fix revealed bugs. 2015-05-18 14:00:19 -04:00
Alex Wood
53fadc2ae2 Rename tests so they have valid Python module names.
Hyphens are not allowed in module names.
2015-05-18 14:00:19 -04:00
Alex Wood
0c4238f8a4 Remove compatibility test for Python 2.4.
The Python 2.4 style of getting an exception object is forbidden by the
test_exceptions_3 test.  Something has to give, and Tito is not being
built for RHEL 5 anymore.
2015-05-15 13:07:35 -04:00
Alex Wood
fb0d60cd6b Add more robust reading in TarFixer.
Python's read(N) function only guarantees that it will read no more
than N bytes but not that it will return N bytes.  This patch adds a
function that will ensure exactly N bytes are read.
2015-05-15 13:07:34 -04:00
Alex Wood
09d89eb4ef Fix tarball timestamps from git archive with Python.
Tito passes "git archive" a tree ID.  The "git archive" man page states:

    git archive behaves differently when given a tree ID versus when
    given a commit ID or tag ID. In the first case the current time
    is used as the modification time of each file in the archive.

Using the current time means that every time we build the source
tarball, the file fingerprint will change since the metadata in the
tarball changes.  We don't want that since build systems track the
fingerprint to see if the actual source has changed.

This process was previously handled in an enigmatic Perl script that
lacked any comments whatsoever.  Converting it to well-commented Python
makes the process less mysterious and speedier since Tito doesn't need
to shell out to Perl.
2015-05-15 13:07:34 -04:00
Devan Goodwin
c4f1755813 Fix failing tests with no ~/.bugzillarc. 2014-06-23 15:01:57 -03:00
Devan Goodwin
d978873738 Fixes for Python 3. 2014-06-23 09:45:41 -03:00
Devan Goodwin
bf19a130a7 Add support for checking bz flags. 2014-06-20 14:53:22 -03:00
Devan Goodwin
48e4fcedca Fix a test issue. 2014-05-16 10:52:01 -03:00
Dominic Cleal
596cb07e68 Remove excess whitespace on EL6 and duplicate SRPM output 2014-05-16 11:08:49 +01:00
Dominic Cleal
5eadb047aa Move compare_version test into correct class 2014-05-12 13:07:09 +00:00
Dominic Cleal
7a032a2d69 Add version comparison utility
Source: http://stackoverflow.com/a/1714190/146925
Credit: gnud <http://stackoverflow.com/users/27204/gnud>
2014-05-09 13:57:53 +01:00
alfen
66baaa4bd2 added rpmbuild output to an error raised by tito to easier the error's cause analysis 2014-04-20 18:55:26 +02:00
Paul Morgan
a398833e72 avoid TB on python3 due to git format string
Use RawConfigParser instead of ConfigParser to avoid...

Traceback (most recent call last):
  File "/home/sandbox/test/functional/multiproject_tests.py", line 68, in setUp
    self.create_project(TEST_PKG_1, os.path.join(self.repo_dir, 'pkg1'))
  File "/home/sandbox/test/functional/fixture.py", line 198, in create_project
    tito('tag --keep-version --debug --accept-auto-changelog')
  File "/home/sandbox/test/functional/fixture.py", line 103, in tito
    return CLI().main(argstring.split(' '))
  File "/home/sandbox/src/tito/cli.py", line 222, in main
    return module.main(argv)
  File "/home/sandbox/src/tito/cli.py", line 671, in main
    offline=self.options.offline)
  File "/home/sandbox/src/tito/tagger/main.py", line 51, in __init__
    ConfigObject.__init__(self, config=config)
  File "/home/sandbox/src/tito/config_object.py", line 38, in __init__
    config.get(section, options))
  File "/usr/lib64/python3.3/configparser.py", line 1184, in set
    super().set(section, option, value)
  File "/usr/lib64/python3.3/configparser.py", line 889, in set
    value)
  File "/usr/lib64/python3.3/configparser.py", line 399, in before_set
    "position %d" % (value, tmp_value.find('%')))
nose.proxy.ValueError: ValueError: invalid interpolation syntax in '%s (%ae)' at position 0
2014-03-11 14:38:03 +00:00
Paul Morgan
3ae1596923 deprecate GitPython
GitPython is not compatible with python3 and may never be:
https://fedoraproject.org/wiki/User:Churchyard/python3
2014-03-09 13:56:17 +00:00