Bug 2019412

Summary: python-docker-squash fails to build with Python 3.11: AttributeError: 'TestSquash' object has no attribute 'assertEquals'
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: python-docker-squashAssignee: Marek Goldmann <mgoldman>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: mgoldman, mhroncok, thrnciar, vrutkovs
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-26 12:29:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1992484, 2016048    

Description Tomáš Hrnčiar 2021-11-02 14:01:11 UTC
python-docker-squash fails to build with Python 3.11.0a1.

=================================== FAILURES ===================================
____________ TestSquash.test_handle_case_when_no_image_is_provided _____________

self = <tests.test_unit_squash.TestSquash testMethod=test_handle_case_when_no_image_is_provided>

    def test_handle_case_when_no_image_is_provided(self):
        squash = Squash(self.log, None, self.docker_client)
        with self.assertRaises(SquashError) as cm:
            squash.run()
>       self.assertEquals(
            str(cm.exception), "Image is not provided")
E       AttributeError: 'TestSquash' object has no attribute 'assertEquals'

tests/test_unit_squash.py:24: AttributeError
_ TestPrepareTemporaryDirectory.test_should_raise_if_directory_already_exists __

self = <tests.test_unit_v1_image.TestPrepareTemporaryDirectory testMethod=test_should_raise_if_directory_already_exists>
mock_path = <MagicMock name='exists' id='140342350414128'>
mock_tempfile = <MagicMock name='tempfile' id='140342350414176'>

    @mock.patch('docker_squash.image.tempfile')
    @mock.patch('docker_squash.image.os.path.exists', return_value=True)
    def test_should_raise_if_directory_already_exists(self, mock_path, mock_tempfile):
        with self.assertRaises(SquashError) as cm:
            self.squash._prepare_tmp_directory('tmp')
>       self.assertEquals(
            str(cm.exception), "The 'tmp' directory already exists, please remove it before you proceed")
E       AttributeError: 'TestPrepareTemporaryDirectory' object has no attribute 'assertEquals'

tests/test_unit_v1_image.py:85: AttributeError
________ TestPrepareLayersToSquash.test_should_generate_list_of_layers _________

self = <tests.test_unit_v1_image.TestPrepareLayersToSquash testMethod=test_should_generate_list_of_layers>

    def test_should_generate_list_of_layers(self):
>       self.assertEquals(self.squash._layers_to_squash(
            ['abc', 'def', 'ghi', 'jkl'], 'def'), (['ghi', 'jkl'], ['abc', 'def']))
E       AttributeError: 'TestPrepareLayersToSquash' object has no attribute 'assertEquals'

tests/test_unit_v1_image.py:108: AttributeError
___ TestPrepareLayersToSquash.test_should_not_fail_with_empty_list_of_layers ___

self = <tests.test_unit_v1_image.TestPrepareLayersToSquash testMethod=test_should_not_fail_with_empty_list_of_layers>

    def test_should_not_fail_with_empty_list_of_layers(self):
>       self.assertEquals(self.squash._layers_to_squash([], 'def'), ([], []))
E       AttributeError: 'TestPrepareLayersToSquash' object has no attribute 'assertEquals'

tests/test_unit_v1_image.py:112: AttributeError
_ TestPrepareLayersToSquash.test_should_return_all_layers_if_from_layer_is_not_found _

self = <tests.test_unit_v1_image.TestPrepareLayersToSquash testMethod=test_should_return_all_layers_if_from_layer_is_not_found>

    def test_should_return_all_layers_if_from_layer_is_not_found(self):
>       self.assertEquals(self.squash._layers_to_squash(
            ['abc', 'def', 'ghi', 'jkl'], 'asdasdasd'), (['abc', 'def', 'ghi', 'jkl'], []))
E       AttributeError: 'TestPrepareLayersToSquash' object has no attribute 'assertEquals'

tests/test_unit_v1_image.py:115: AttributeError
________________ TestGenerateV1ImageId.test_should_generate_id _________________

self = <tests.test_unit_v1_image.TestGenerateV1ImageId testMethod=test_should_generate_id>

    def test_should_generate_id(self):
        image_id = self.squash._generate_image_id()
>       self.assertEquals(len(image_id), 64)
E       AttributeError: 'TestGenerateV1ImageId' object has no attribute 'assertEquals'

tests/test_unit_v1_image.py:129: AttributeError
_ TestGenerateV1ImageId.test_should_generate_id_that_is_not_integer_shen_shortened _

self = <tests.test_unit_v1_image.TestGenerateV1ImageId testMethod=test_should_generate_id_that_is_not_integer_shen_shortened>
mock_random = <MagicMock name='sha256' id='140342364042000'>

    @mock.patch('docker_squash.image.hashlib.sha256')
    def test_should_generate_id_that_is_not_integer_shen_shortened(self, mock_random):
        first_pass = mock.Mock()
        first_pass.hexdigest.return_value = '12683859385754f68e0652f13eb771725feff397144cd60886cb5f9800ed3e22'
    
        second_pass = mock.Mock()
        second_pass.hexdigest.return_value = '10aaeb89980554f68e0652f13eb771725feff397144cd60886cb5f9800ed3e22'
    
        mock_random.side_effect = [first_pass, second_pass]
        image_id = self.squash._generate_image_id()
>       self.assertEquals(mock_random.call_count, 2)
E       AttributeError: 'TestGenerateV1ImageId' object has no attribute 'assertEquals'

tests/test_unit_v1_image.py:142: AttributeError
___________ TestGenerateRepositoriesJSON.test_handle_empty_image_id ____________

self = <tests.test_unit_v1_image.TestGenerateRepositoriesJSON testMethod=test_handle_empty_image_id>

    def test_handle_empty_image_id(self):
        with mock.patch.object(six.moves.builtins, 'open', mock.mock_open()) as mock_file:
            with self.assertRaises(SquashError) as cm:
                self.squash._generate_repositories_json(
                    'file', None, 'name', 'tag')
    
>           self.assertEquals(
                str(cm.exception), 'Provided image id cannot be null')
E           AttributeError: 'TestGenerateRepositoriesJSON' object has no attribute 'assertEquals'

tests/test_unit_v1_image.py:170: AttributeError
__________________ TestPathHierarchy.test_should_handle_empty __________________

self = <tests.test_unit_v1_image.TestPathHierarchy testMethod=test_should_handle_empty>

    def test_should_handle_empty(self):
        with self.assertRaises(SquashError) as cm:
            self.squash._path_hierarchy('')
>       self.assertEquals(
            str(cm.exception), "No path provided to create the hierarchy for")
E       AttributeError: 'TestPathHierarchy' object has no attribute 'assertEquals'


Removed many old deprecated unittest features:
    TestCase method aliases failUnlessEqual, failIfEqual, failUnless, failIf,
    failUnlessRaises, failUnlessAlmostEqual, failIfAlmostEqual (deprecated in
    Python 3.1), assertEquals, assertNotEquals, assert_, assertAlmostEquals,
    assertNotAlmostEquals, assertRegexpMatches, assertRaisesRegexp (deprecated in
    Python 3.2), and assertNotRegexpMatches (deprecated in Python 3.5).

https://bugs.python.org/issue45162
https://docs.python.org/3.11/whatsnew/3.11.html


For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.11/fedora-rawhide-x86_64/02911382-python-docker-squash/

For all our attempts to build python-docker-squash with Python 3.11, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/package/python-docker-squash/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.11:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/

Let us know here if you have any questions.

Python 3.11 is planned to be included in Fedora 37. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.11.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Marek Goldmann 2021-11-26 12:29:25 UTC
Fixed in python-docker-squash-1.0.9-1.fc36.