On 05/17/22 12:11, Richard W.M. Jones wrote: > > OK I see what's going on. > > test-S3.sh uses the mocked boto3 in tests/test-S3/ to do an end-to-end > test (nbdcopy). > > test-S3-unit.sh runs the unit tests within the plugin. It's basically > testing the plugin as if it was a standalone Python script (without > nbdkit being involved). This uses an internal MockS3Client class also > inside the plugin. > > The second one does actually need real boto3, just because there's an > "import boto3" at the top and we don't set up PYTHONPATH to pick up > the tests/test-S3/ subdirectory. > > We could either fix the second one by skipping it if (real) boto3 > isn't installed, or by making it use the mocked boto3 from tests/test-S3/ > > Either approach would work, but the second one (below) seems maybe > better because we'd get more test coverage this way?
I think so, yes: from your description, "test-S3-unit.sh" seems "less demanding" than "test-S3.sh", so if the mocked module satisfies the latter, it should be good enough for the former too. > > Rich. > > > diff --git a/tests/test-S3-unit.sh b/tests/test-S3-unit.sh > index 6b6adf02..11718be3 100755 > --- a/tests/test-S3-unit.sh > +++ b/tests/test-S3-unit.sh > @@ -44,6 +44,6 @@ if [ "$NBDKIT_VALGRIND" = "1" ]; then > exit 77 > fi > > -export PYTHONPATH=$srcdir/../plugins/S3:$PYTHONPATH > +export PYTHONPATH=$srcdir/../plugins/S3:$srcdir/test-S3:$PYTHONPATH > > $PYTHON -m unittest S3 > > For this hunk above: Acked-by: Laszlo Ersek <[email protected]> Thanks Laszlo _______________________________________________ Libguestfs mailing list [email protected] https://listman.redhat.com/mailman/listinfo/libguestfs
