pmbootstrap-meow/test/test_mount.py
Oliver Smith e605a0af32
test/pmb_test: prepare for common test code (!1876)
Replace the "Add topdir to import path" boilerplate lines in each test
file with a simple "import pmb_test". Use the "# noqa" comment if
"pmb_test" is not used further in the test file, so flake8 does not
complain about an unused module.

Make the path to the testdata available as pmb_test.const.testdata, and
use pmb.config.pmb_src to access the topdir in all tests.

This is in preparation for new "pmbootstrap status" related tests, which
will have shared test code in test/pmb_test/. Also, this makes the
pmbootstrap codebase more consistent with the bpo codebase, which has a
similar "import bpo_test" mechanism.
2020-02-24 03:01:04 +03:00

41 lines
1.5 KiB
Python

"""
Copyright 2020 Oliver Smith
This file is part of pmbootstrap.
pmbootstrap is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
pmbootstrap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
import pmb_test # noqa
import pmb.helpers.mount
def test_umount_all_list(tmpdir):
# Write fake mounts file
fake_mounts = str(tmpdir + "/mounts")
with open(fake_mounts, "w") as handle:
handle.write("source /test/var/cache\n")
handle.write("source /test/home/pmos/packages\n")
handle.write("source /test\n")
handle.write("source /test/proc\n")
handle.write("source /test/dev/loop0p2\\040(deleted)\n")
ret = pmb.helpers.mount.umount_all_list("/no/match", fake_mounts)
assert ret == []
ret = pmb.helpers.mount.umount_all_list("/test/var/cache", fake_mounts)
assert ret == ["/test/var/cache"]
ret = pmb.helpers.mount.umount_all_list("/test", fake_mounts)
assert ret == ["/test/var/cache", "/test/proc", "/test/home/pmos/packages",
"/test/dev/loop0p2", "/test"]