Page MenuHomeSoftware Heritage

Move common test utility function to the top-level arborescence
ClosedPublic

Authored by ardumont on Jul 6 2020, 3:32 PM.

Details

Summary

It's shared amongst both package and core loaders.

This will avoid importing different helper utility functions from different
modules.

This also fixes captured error on assert_last_visit_matches when the
assertion is failing regarding the visit_status snapshot comparison.

Related to T2481

Test Plan

tox

Event Timeline

Build is green

Patch application report for D3432 (id=12150)

Could not rebase; Attempt merge onto aafac87f5c...

Updating aafac87..373e9a1
Fast-forward
 MANIFEST.in                                       |  1 +
 swh/loader/core/tests/__init__.py                 |  2 +-
 swh/loader/core/tests/test_loader.py              |  2 +-
 swh/loader/package/archive/tests/test_archive.py  |  2 +-
 swh/loader/package/cran/tests/test_cran.py        |  2 +-
 swh/loader/package/debian/tests/test_debian.py    |  2 +-
 swh/loader/package/deposit/tests/test_deposit.py  |  2 +-
 swh/loader/package/nixguix/tests/test_nixguix.py  |  2 +-
 swh/loader/package/npm/tests/test_npm.py          |  2 +-
 swh/loader/package/pypi/tests/test_pypi.py        |  2 +-
 swh/loader/tests/__init__.py                      | 78 +++++++++++++++++++++++
 swh/loader/tests/common.py                        | 53 ---------------
 swh/loader/tests/data/0805nexter-1.1.0.tar.gz     |  1 +
 swh/loader/tests/{test_common.py => test_init.py} | 50 +++++++++++++--
 14 files changed, 134 insertions(+), 67 deletions(-)
 delete mode 100644 swh/loader/tests/common.py
 create mode 120000 swh/loader/tests/data/0805nexter-1.1.0.tar.gz
 rename swh/loader/tests/{test_common.py => test_init.py} (63%)
Changes applied before test
commit 373e9a16e967ad241865b69f1d8cbdf188b86bac
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Mon Jul 6 14:49:40 2020 +0200

    Move common test utility function to the top-level arborescence
    
    It's shared amongst both package and core loaders.
    
    Related to T2481

commit 3348e522ccfd8a217c015eada42731cbbc7ca0a3
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Mon Jul 6 14:41:05 2020 +0200

    Define common test helper function
    
    Related to T2481

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

olasd added a subscriber: olasd.
olasd added inline comments.
swh/loader/tests/__init__.py
54

This string needs a f (just noticed that while breaking the git loader tests...). I also suggest using .hex() instead of !r.

This revision is now accepted and ready to land.Jul 6 2020, 4:41 PM
swh/loader/tests/__init__.py
54

heh, nice catch ;)

Adapt according to review:

  • Add missing f string prefix
  • use .hex
  • Add the necessary assert for mypy to be happy

Build is green

Patch application report for D3432 (id=12162)

Could not rebase; Attempt merge onto aafac87f5c...

Updating aafac87..4084012
Fast-forward
 MANIFEST.in                                       |  1 +
 swh/loader/core/tests/__init__.py                 |  2 +-
 swh/loader/core/tests/test_loader.py              |  2 +-
 swh/loader/package/archive/tests/test_archive.py  |  2 +-
 swh/loader/package/cran/tests/test_cran.py        |  2 +-
 swh/loader/package/debian/tests/test_debian.py    |  2 +-
 swh/loader/package/deposit/tests/test_deposit.py  |  2 +-
 swh/loader/package/nixguix/tests/test_nixguix.py  |  2 +-
 swh/loader/package/npm/tests/test_npm.py          |  2 +-
 swh/loader/package/pypi/tests/test_pypi.py        |  2 +-
 swh/loader/tests/__init__.py                      | 79 +++++++++++++++++++++++
 swh/loader/tests/common.py                        | 53 ---------------
 swh/loader/tests/data/0805nexter-1.1.0.tar.gz     |  1 +
 swh/loader/tests/{test_common.py => test_init.py} | 50 ++++++++++++--
 14 files changed, 135 insertions(+), 67 deletions(-)
 delete mode 100644 swh/loader/tests/common.py
 create mode 120000 swh/loader/tests/data/0805nexter-1.1.0.tar.gz
 rename swh/loader/tests/{test_common.py => test_init.py} (63%)
Changes applied before test
commit 4084012c0ad7e451ed229c0dc8220543591adc65
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Mon Jul 6 14:49:40 2020 +0200

    Move common test utility function to the top-level arborescence
    
    It's shared amongst both package and core loaders.
    
    Related to T2481

commit 3348e522ccfd8a217c015eada42731cbbc7ca0a3
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Mon Jul 6 14:41:05 2020 +0200

    Define common test helper function
    
    Related to T2481

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