forked from Mirror/pmbootstrap
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.
This commit is contained in:
parent
4a08b5e066
commit
e605a0af32
36 changed files with 116 additions and 155 deletions
|
@ -21,9 +21,8 @@ import os
|
|||
import pytest
|
||||
import sys
|
||||
|
||||
# Import from parent directory
|
||||
pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
|
||||
sys.path.insert(0, pmb_src)
|
||||
import pmb_test
|
||||
import pmb_test.const
|
||||
import pmb.aportgen.device
|
||||
import pmb.config
|
||||
import pmb.config.init
|
||||
|
@ -104,7 +103,7 @@ def test_questions_bootimg(args, monkeypatch):
|
|||
fake_answers(monkeypatch, ["invalid_path", ""])
|
||||
assert func(args) is None
|
||||
|
||||
bootimg_path = pmb_src + "/test/testdata/bootimg/normal-boot.img"
|
||||
bootimg_path = pmb_test.const.testdata + "/bootimg/normal-boot.img"
|
||||
fake_answers(monkeypatch, [bootimg_path])
|
||||
output = {"base": "0x80000000",
|
||||
"kernel_offset": "0x00008000",
|
||||
|
@ -120,7 +119,7 @@ def test_questions_bootimg(args, monkeypatch):
|
|||
|
||||
def test_questions_device(args, monkeypatch):
|
||||
# Prepare args
|
||||
args.aports = pmb_src + "/test/testdata/init_questions_device/aports"
|
||||
args.aports = pmb_test.const.testdata + "/init_questions_device/aports"
|
||||
args.device = "lg-mako"
|
||||
args.nonfree_firmware = True
|
||||
args.nonfree_userland = False
|
||||
|
@ -157,7 +156,7 @@ def test_questions_device(args, monkeypatch):
|
|||
|
||||
def test_questions_device_kernel(args, monkeypatch):
|
||||
# Prepare args
|
||||
args.aports = pmb_src + "/test/testdata/init_questions_device/aports"
|
||||
args.aports = pmb_test.const.testdata + "/init_questions_device/aports"
|
||||
args.kernel = "downstream"
|
||||
|
||||
# Kernel hardcoded in depends
|
||||
|
@ -177,7 +176,7 @@ def test_questions_device_kernel(args, monkeypatch):
|
|||
|
||||
def test_questions_device_nonfree(args, monkeypatch):
|
||||
# Prepare args
|
||||
args.aports = pmb_src + "/test/testdata/init_questions_device/aports"
|
||||
args.aports = pmb_test.const.testdata + "/init_questions_device/aports"
|
||||
args.nonfree_firmware = False
|
||||
args.nonfree_userland = False
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue