Week 4 - Finding my Stride

TedLawson
Published: 06/27/2023

Accomplishments:

Xattr tests PR got merged this week, and the Repo tests are completed and waiting on final approval. It feels really good to have these finished up! The biggest accomplishment this week, however, was converting all of the archiver unit test base functions to pytest. These archiver unit test base functions were the groundwork for all 20 test files in the archiver folder, and by getting these converted into pytest fixtures I was able to begin quickly making inroads to the remaining test files still needing conversion to pytest. I was able to get the unit test functions converted to pytest by Tuesday, and then I was able to complete at least one test file each day this week, and even a little extra over the weekend during a long flight! It felt great to move so quickly through these files, and I feel like I am finally finding my stride and keeping to a pace that I can be proud of.

Challenges:

This week saw surprisingly few challenges. One issue I hit, however, was when trying to convert some helper functions from the unittest base to pytest fixtures so they could be used by all the test files. Here is an example of the function that I would need to convert:

def open_archive(self, name):
    repository = Repository(self.repository_path, exclusive=True)
    with repository:
        manifest = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
        archive = Archive(manifest, name)
    return archive, repository

When I originally tried to convert this to a pytest fixture, I did something like this:

@pytest.fixture()
def open_archive(archiver):
    def archive_and_repository(name):
        repo_path = archiver.repository_path
        repository = Repository(repo_path, exclusive=True)
        with repository:
            manifest = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
            archive = Archive(manifest, name)
        return archive, repository

    return archive_and_repository

What I realized, however, was that these type of helper functions should not be fixtures at all. Instead, they should be functions placed in a utils module, and imported by the tests. My mentor gave me a good rule of thumb: Fixtures should only be used if there is a specific setup or teardown being preformed,  while helper functions should be instead placed in a utils package.

The week ahead: 

This week I have a meeting with my mentor, Manu, set up for Wednesday morning. I will also be attending the GSoC contributor mid-summer evaluation meeting on Tuesday morning. Other than the two meetings, I will be continuing to work through the rest of the archiver test folder. I am working quite quickly through these and anticipate being finished with 10 of the 20 test files by the end of the week.

Thanks to everyone for reading, and I look forward to updating on my progress again next week!

DJDT

Versions

Time

Settings from gsoc.settings

Headers

Request

SQL queries from 1 connection

Static files (2312 found, 3 used)

Templates (11 rendered)

Cache calls from 1 backend

Signals

Log messages