cc_mounts: fix incorrect format specifiers#316
Conversation
LP: #1872836
| @mock.patch(M_PATH + 'util.subp') | ||
| def test_happy_path(self, m_subp, tmpdir): | ||
| swap_file = tmpdir.join("swap-file") | ||
| fname = str(swap_file) |
There was a problem hiding this comment.
isn't this just swap_file.strpath?
There was a problem hiding this comment.
We had to use swap_file.strpath in ubuntu-advantage-tools because str(swap_file) didn't work in the version of pytest in trusty. However, using str() is preferable because it works against more types, so if swap_file changes type for whatever reason then this line doesn't need changing.
(And there is a slight practical component to this: more recent versions of pytest have introduced the tmp_path fixture which returns an instance of the stdlib's pathlib.Path instead of the third-party-and-in-maintenance-mode py library's py.path.LocalPath. str(tmp_path.joinpath(...)) behaves the same as str(tmpdir.join(...)), but tmp_path.joinpath(...).strpath raises an AttributeError. Eventually (after we're no longer backporting to bionic, now that I look at the version tmp_path was introduced in), we'll want to migrate to tmp_path.)
blackboxsw
left a comment
There was a problem hiding this comment.
Minor nit on the unit test and we can skip the unhappy_path test given the timeliness of the release and it basically exercises the same type of logic fix.
LP: #1872836