Page MenuHomeSoftware Heritage

test_serializers: Refactor using pytest
ClosedPublic

Authored by ardumont on Jul 8 2020, 3:24 PM.

Details

Summary

Kept the data as is.
Change from unittest form to pytest one.

Related to D3460

Test Plan

tox

Diff Detail

Repository
rDCORE Foundations and core functionalities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

ardumont created this revision.Jul 8 2020, 3:24 PM

Build is green

Patch application report for D3461 (id=12255)

Rebasing onto 737b21d3dd...

Current branch diff-target is up to date.
Changes applied before test
commit 4af761b0be7c6a922fe0e2bb919d5a9a93c6c1d7
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Wed Jul 8 15:24:56 2020 +0200

    test_serializers: Refactor using pytest
    
    Related to D3460

See https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/20/ for more details.

ardumont edited the summary of this revision. (Show Details)Jul 8 2020, 3:27 PM
vlorentz added inline comments.
swh/core/api/tests/test_serializers.py
64–65

make it a constant

164

concat

192

concat

ardumont added inline comments.Jul 8 2020, 3:42 PM
swh/core/api/tests/test_serializers.py
64–65

Is it really needed?

it's only once below to avoid black explode the datetime into one line per datetime attribute...

ardumont updated this revision to Diff 12260.Jul 8 2020, 3:43 PM

Adapt according to review (concat blackified strings)

Build is green

Patch application report for D3461 (id=12260)

Could not rebase; Attempt merge onto 737b21d3dd...

Updating 737b21d..acf12b4
Fast-forward
 setup.py                               |   4 +-
 swh/core/api/tests/test_serializers.py | 253 +++++++++++++++++----------------
 2 files changed, 130 insertions(+), 127 deletions(-)
Changes applied before test
commit acf12b46a9e04fcc7038094ac64b8f5108030696
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Wed Jul 8 15:24:56 2020 +0200

    test_serializers: Refactor using pytest
    
    Related to D3460

commit 0f62f75eb46e1bd70d4a693eae1f46afb04f25ef
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Wed Jul 8 15:29:51 2020 +0200

    Migrate from vcversioner to setuptools-scm
    
    Related to T2105

See https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/23/ for more details.

vlorentz added inline comments.Jul 9 2020, 10:37 AM
swh/core/api/tests/test_serializers.py
64–65

I mean, it doesn't have to be a function/fixture. You can do

DATA = {
    ...
}

at the toplevel.

I don't see what black has to do with that

ardumont updated this revision to Diff 12302.Jul 9 2020, 2:43 PM

Adapt according to good remark, make DATA and ENCODED_DATA constants (no need
for a pytest fixture indeed)

Build is green

Patch application report for D3461 (id=12302)

Rebasing onto 0f62f75eb4...

Current branch diff-target is up to date.
Changes applied before test
commit 028ef739da913a4460a378a8bb7851d85abdf408
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Wed Jul 8 15:24:56 2020 +0200

    test_serializers: Refactor using pytest
    
    Related to D3460

See https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/24/ for more details.

ardumont added inline comments.Jul 9 2020, 2:47 PM
swh/core/api/tests/test_serializers.py
64–65

We misunderstood each other ;).

You were asking me to drop the data fixture altogether (to make its data as
constant).

I was speaking only about the variable tz (which i thought you wanted as
constant ¯\_(ツ)_/¯). And that i extracted so black did not explode the
datetime.

In the end, everything is fine. I did the fixture to constant change, it's
simpler ;)

vlorentz accepted this revision.Jul 9 2020, 10:30 PM
This revision is now accepted and ready to land.Jul 9 2020, 10:30 PM
This revision was automatically updated to reflect the committed changes.