cros_test_lib: turn self.tempdir into a Path object
Path objects are easier to work with than plain strings, so convert
self.tempdir into it. This allows us to cleanup some tests that were
already converting self.tempdir to a Path.
For tests that use protobufs, we often have to coerce the path back
into a string because the bindings don't understand Path types.
For some APIs we keep coercing Paths to strings. Hopefully by moving
self.tempdir to Path, we can encourage more natural conversion of code
to pathlib, and to have new code use pathlib from the start.
BUG=None
TEST=unittests pass
Change-Id: I6afb531489332dc0599c6b4a41307f258debfdfc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3612622
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Ram Chandrasekar <rchandrasekar@google.com>
Commit-Queue: Ram Chandrasekar <rchandrasekar@google.com>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/api/controller/artifacts_unittest.py b/api/controller/artifacts_unittest.py
index 33d989a..d1ec749 100644
--- a/api/controller/artifacts_unittest.py
+++ b/api/controller/artifacts_unittest.py
@@ -120,7 +120,7 @@
def testNoBuildTarget(self):
"""Test that no build target fails."""
- request = self.BuildTargetRequest(output_dir=self.tempdir)
+ request = self.BuildTargetRequest(output_dir=str(self.tempdir))
with self.assertRaises(cros_build_lib.DieSystemExit):
artifacts.BundleImageArchives(request, self.response, self.api_config)
@@ -874,7 +874,7 @@
request = artifacts_pb2.BundleRequest()
request.build_target.name = 'board'
- request.output_dir = self.tempdir
+ request.output_dir = str(self.tempdir)
artifacts.ExportCpeReport(request, self.response, self.validate_only_config)
@@ -886,7 +886,7 @@
request = artifacts_pb2.BundleRequest()
request.build_target.name = 'board'
- request.output_dir = self.tempdir
+ request.output_dir = str(self.tempdir)
artifacts.ExportCpeReport(request, self.response, self.mock_call_config)
@@ -899,7 +899,7 @@
def testNoBuildTarget(self):
request = artifacts_pb2.BundleRequest()
- request.output_dir = self.tempdir
+ request.output_dir = str(self.tempdir)
with self.assertRaises(cros_build_lib.DieSystemExit):
artifacts.ExportCpeReport(request, self.response, self.api_config)
@@ -912,7 +912,7 @@
request = artifacts_pb2.BundleRequest()
request.build_target.name = 'board'
- request.output_dir = self.tempdir
+ request.output_dir = str(self.tempdir)
artifacts.ExportCpeReport(request, self.response, self.api_config)